I need help with my project

This forum is currently in read-only mode.
  • Hi there

    Couple of things that i want to understand but i cant figure out. Been pondering about this for hours.

    *** Please download the .cap file to understand what i'm talking about. ***

    http://internet.is/eski/buttongame.cap

    1. I'm trying to code this so i can only select one item at a time, basicly only shoot one item and when it has stopped you can shoot another. I have tried to have loop, for each, always and all, just cant get it to work.

    I have tried to compare the velocity of the items to 0 but it randomly selects items so it doesn't always work.

    2. I'm trying to make the line be maximum length off 300 pixels.

    3. There are two "teams" blue and red. Its the same sprite, blue is one animation and red is another. So basicly i just change the animation. Ok so i'm trying to make a textbox in the corner count the total of each team. I have tried to use AV 0 for blue and 1 for red and used a event like this

    Sprite Value Team Equal 0

    • Set text to Sprite.Count

    Should this not work right, it gives me the total, counts the blue and red.

    I also tried to use a event that checked what animation was playing, same story.

    I know i have asked alot of questions on this forum but i am really eager to learn basicly everything about construct

    PS.

    Can i Spread Values in AV on Instances to know them from each other ? Like puting ID's on them.

    Whats the diff from uID and oID ?

    Can Sprites have transistions when creating and destroying ? (or do i have to program them like fading)

  • 1. I'm trying to code this so i can only select one item at a time, basicly only shoot one item and when it has stopped you can shoot another. I have tried to have loop, for each, always and all, just cant get it to work.

    The easiest way is to click the mouse to choose a piece, then release the mouse to shoot it. You can still cancel with right-click this way.

    What's happening is that your Click triggers are both triggering at once, that's why you're choosing more than one piece at a time.

    2. I'm trying to make the line be maximum length off 300 pixels.

    You can do this with clamp(). Clamp restricts a number between two other numbers. Like so:

    clamp(target value [this is the actual mouse distance], minimum value [this is the lowest the width should be], maximum value [this is the longest it should be])

    Abbreviated: clamp(target, min, max)

    The easiest way to make your line stop at 300 pixels is by using the sprite object, because you can easily set the width. I changed it to sprite object and did the following:

    Set width to: clamp(distance(line.x, line.y, mouseX, mouseY) - 5, 10, 290)

    I set the target to mouse-distance-minus-5 so that the edge of the sprite wouldn't poke out past the point of the arrowhead. The min length is 10, and the max length is 290 instead of 300, again so the end won't poke out past the arrowhead.

    Setting the arrowhead distance and position is a bit trickier. You basically have to orbit it around the line object's x and y. I used cos and sin to find the position:

    Set angle to: angle(line.x, line.y, mousex, mousey)

    Set X to: line.x+cos(Sprite3.angle)*clamp(distance(line.x, line.y, mouseX, mouseY), 10, 300)

    Set Y to: line.y+sin(Sprite3.angle)*clamp(distance(line.x, line.y, mouseX, mouseY), 10, 300)

    You may be able to use the Orbiter or Custom Movement behavior for that instead, if you don't like math. I just happened to have the orbit expression laying around from another project and I reused it.

    The Custom Movement behavior has actions that will restrict the distance an object is from a point though, so it shouldn't be too hard to figure out.

    3. There are two "teams" blue and red. Its the same sprite, blue is one animation and red is another. So basicly i just change the animation. Ok so i'm trying to make a textbox in the corner count the total of each team. I have tried to use AV 0 for blue and 1 for red and used a event like this

    Sprite Value Team Equal 0

    - Set text to Sprite.Count

    Should this not work right, it gives me the total, counts the blue and red.

    Apparently .Count isn't respecting the Selected Object List. You can get around that by using a For Each loop and picking the sprites by their Team value. Example in the .cap below.

    Can i Spread Values in AV on Instances to know them from each other ? Like puting ID's on them.

    Can Sprites have transistions when creating and destroying ? (or do i have to program them like fading)

    You don't need to spread values in Construct. The picking system generally knows what you're talking about as long as you keep your conditions straight. On the off chance you come across a situation that doesn't pick what you want, try a For Each coupled with the condition you're using to pick with.

    As for sprite transitions, you pretty much have to make your own. There is a Fade behavior you can put on your sprites that might help you out, but the way you're doing it now is pretty much right on the money.

    Anyway, here's the .cap with the changes I made. I didn't comment anything though so if you have any questions about what I did feel free to ask.

    http://dl.dropbox.com/u/529356/shuffleboardThing.cap

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • By the way, that's a cool little idea for a game . Nice and simple, but still requires skill. Like billiards.

  • wow that was a good answear

    few things..

    How would i go to shoot only one item at a time but all items have to be stopped to do so ? Compare the velocity of all the items to 0 ? For each loop ?

    I have always used system create object, you use spawn object.. is there difference between the two ?

    The difference between uID and oID ?

    When you are using for each command and loops and all that, do you have to set the addidional events as sub events ? (Like you do with the text counter)

    Thanks for the complement, i like the concept of the game, going to change the graphics when i have finished the game engine

    Btw... Thats some math calculations you used there, nice work ;D

  • How would i go to shoot only one item at a time but all items have to be stopped to do so ? Compare the velocity of all the items to 0 ? For each loop ?

    You might try setting a global variable like global('shoot') to 1 when a puck is shot. Then you can do something like this:

    + Global('shoot') = 1
        + puckSprite.Value('clicked') = 1
        + PuckSprite: Physics: Velocity = 0
            -> Set global('shoot') to 0
    [/code:1v78g7jh]
    
    Then you could use the shoot variable as a condition when clicking on a puck.
    
    

    I have always used system create object, you use spawn object.. is there difference between the two ?

    They are similar, but spawning will set the angle of the created object to the angle of the originating object automatically. There might be some other differences, I can't quite remember at the moment, I just woke up and haven't had my coffee yet. Check the wiki.

    The difference between uID and oID ?

    UID is unique to each instance of an object, OID is the same for each instance of an object. You will very rarely ever have to use them since the picking in Construct is pretty solid, not like in MMF.

    When you are using for each command and loops and all that, do you have to set the addidional events as sub events ? (Like you do with the text counter)

    It depends on what you're doing. Since I was doing two different things to two different groups of the same object, I split them up into two different sub-events.

    If you are performing the same actions on every object in your For Each, you can stack the conditions in the same event as the For Each.

    Btw... Thats some math calculations you used there, nice work ;D

    It wasn't really me... Probably Madster or Lucid or Quazi. I suck at math . I just keep little snippets of math like that for use whenever I need them.

  • Allright, dont i have to compare the global variable shoot to 0 when i click on a puck ?

    +on left mouse button click on pucksprite

    +global variable shoot = 0

    -> do shoot stuff and that

    With this i can only shoot one time and then its frozen at shoot 1.

    I should use Sprite[Physics].AngularVelocity right ?

  • Hey, nice game concept!

  • thanks

  • i think the problem is that construct doesnt know the diffrence between the instances..

    I feel that is the problem, maybe i'm wrong.

    For example

    +On left mouse click on Sprite

    +Sprite Velocity = 0

    • -> Set global variable shoot = 1

    I feel like it takes a random sprite and checks that the velocity is 0 because sometimes it works and sometimes not...

    Could it be some problem with the instances ?

    Do i have to compare the uID on the clicked item to make sure that is the same item.. ?

  • OK !

    finally i found a way to make it work, dont know if its the "right" way but its working.. but please comment on it

    other thing that i cant figure out with the physics.. it so slow at stopping..

    The speed and the contact damping is the way i like but its so slow to reach the point of zero speed, you can see the AV "speed" on the sprites what i'm talking about.

    Anyways the file is here.

    http://internet.is/eski/shuffleboardThing.cap

    edit: aahh.. took out some crap that i figured out

    but there is a bug in the 0.99.97 construct...

    If you have done some changes on a .cap file and quit the program it just shuts right off..

    it doesnt ask you if you want to save the changes that you have maked.. didnt do this in version before this one (i think)

  • Okay eski, sorry for the delay. I got what you're looking for here, to help slow down your pucks faster.

    I changed event 15 to this:

    + System: For each Sprite
         -> Sprite: Set 'Speed' to sqrt(Sprite[Physics].VelocityX^2+Sprite[Physics].VelocityY^2)
         -> Sprite: Set 'id' to Sprite.UID[/code:3mk0s3gm]
    
    The way you had it before, you were just setting Speed to the X velocity.  This combines the X and Y velocity to get total velocity.  The ^2 also changes it so that you always get a positive number.
    
    (You can thank Quazi for that one, he helped me figure that out in this thread: )
    
    Anyway, back to the .cap.  I un-toggled the last event you had (event 22) and changed it to this:
    
    [code:3mk0s3gm]+ Sprite: Pick by Sprite.Value('Speed') Greater than 0
    + Sprite: Pick by Sprite.Value('Speed') Lower than 2
        -> Sprite: Set velocity to (0, 0)[/code:3mk0s3gm]
    
    I used Sprite compare rather than System compare so the picking would work properly.  You can find it in the Sprite conditions labeled "Pick by comparison."  I used "Lower than 2" just to stop them faster, you could probably get away with 3 or 4 and it wouldn't look too weird.
  • ahhh brilliant..

    now its starting to feel good.

    Next is improving the graphics and putting in some power ups.. nah.. just the graphics

    Thanks alot deadeye for the help and Quazi...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)