Logically speaking I am confused

jbsitedesignjbsitedesign Member Posts: 25
edited November -1 in Working with GS (Mac)
Trying to create a relatively simple duck and jump obstacle dodging style game. Having problems with logic for moving obstacles onto the screen. Trying to recycle obstacle objects to avoid overhead problems and such. I've used display text to debug the situation to no avail as i get the expected behavior results from the debug. Anyway to the meat of it:

I have 3 objects named Mud Puddle 1, Mud Puddle 2, and Mud Puddle 3.
I have 3 boolean Game attributes Puddle Go, Puddle 2 Go, and Puddle 3 Go
I have a Game attribute Min Distance
Game attribute Total Distance
Game attribute Previous Distance

when the game starts all the booleans are set to false and the distances are set to zero.

with a timer each tenth of a second the total distance is solved by taking the scroll speed of the ground level (upon which the player "runs") multiplied by elapsed time(game time - previous time ; prev time = gametime) and adding it to the existing total distance.

minimum distance just makes sure two obstacles are not place so close together that the player does not have time to "jump" over them. it is solved by taking .7(jump time solved with debug) multiplied by the scroll speed(stored in a game variable) plus the width of an obstacle which all are the same to make it "easier" lol easier i say lol

so here is the logic:

If (min distance < total distance - previous distance)
If (puddle go = false)
puddle go = true
previous distance = total distance
else if (puddle 2 go = false)
puddle 2 go = true
previous distance = total distance
else if ( puddle 3 go = false)
puddle 3 go = true
previous distance = total distance

inside of the 3 seperate puddle objects is a boolean attirbute "is going" and logic similar to:

If ( game.Puddle X go = true and is going = false)
Move to the right edge of the screen just offscreen
set my X velocity to match the ground scroll velocity
set boolean 'is going = true'

if (my location takes me offscreen to the left)
set Game.Puddle x Go = false
set is going = false
stop velocity

if (is going = true)
update the horizontal velocity to again match the scroll velocity <---this is done because scroll velocity is increasing every second inside the game controller object

HERE IS THE PROBLEM:

at the start of the game all 3 mud puddle immediately begin to behave as if Puddle X Go is set to true although i have rechecked and yes these attributes have a default value of false.
they all set position offscreen right and start moving to the left at the same speed as ground scroll.

after the first cycle completes and they all go offscreen left they all do set their go values back to false and the process can start again.....only

on the second cycle the first and third object begin to behave as expected however the second object appears to completely ignore the logic and is working in lockstep with the first object.

i have checked and rechecked the logic to make sure that it actually matches the intented
i have used display text to make sure that all booleans are only being changed at the proper moments
i have used display text to ensure that the distance calculations are being performed and make sense
i have used display text to check that the elapsed timing is correct.
all of these debugs return values that seem to support the logic is working and yet the behavior of the objects says clearly that it is not. PLEASE help. I am completely out of ideas here. Thank you.

Comments

  • jbsitedesignjbsitedesign Member Posts: 25
    will gladly share project with an experienced person as i realize things are getting complex here lol
  • hotMagichotMagic Member, PRO Posts: 266
    What I would do is comment out all that complex logic, copy and paste just the move part to outside of the logic as a control group test.

    If you take out the puddle Go part, and just assign each one to move on a keystroke, that would be a good debug test.

    Have you tried that?
  • jbsitedesignjbsitedesign Member Posts: 25
    Yes, they do move as desired actually its the timing of their movements that is a problem.....there should be a gap between them but objects 1 and 2 move in lockstep. :( Also, i have coded for a few years in C# for xbox360 and android games so the logic is not that complex to me but it doesnt seem to work here in game salad. its probably just that i am not used to the visual presentation and am making some dumb mistake so i wouldnt mind sharing the file.
  • hotMagichotMagic Member, PRO Posts: 266
    I'd be happy to take a second look at it if you want to show me the project. If you just hard-code the interval numbers, do they come out separately? Just had a thought that maybe the only bug is in that math that assigns the time intervals...
Sign In or Register to comment.