Computer Science Canada Boundaries For Game Using Sprites |
Author: | PuterFreak [ Wed Jun 09, 2004 5:10 pm ] |
Post subject: | Boundaries For Game Using Sprites |
if x1 = maxx then loop for x : 1 .. 2 Pic.Draw (zf (x), maxx, y1, picCopy) end for end loop else end if this is what i have and it seems logical to me ... if the sprites x position is equal to maxx then redraw the sprite (which is an array of 2 pictures) at maxx thus disableing to move off the screen.... but im a moron and it dont work .... anyone up for helping? |
Author: | PuterFreak [ Wed Jun 09, 2004 5:12 pm ] |
Post subject: | |
sory bout double postin but this is the line if x1 = maxx then loop for x : 1 .. 2 Pic.Draw (zf (x), maxx, y1, picCopy) end for end loop end if (no else) =p |
Author: | Cervantes [ Wed Jun 09, 2004 7:53 pm ] | ||||
Post subject: | |||||
try changing
to
you are probably moving the sprite by incriments of more than 1 each time through the loop to make it go reasonably fast, and if that's the case, it, depending on its starting position, could jump over the maxx. ie. go from maxx - 1 to maxx + 1 and the if x1 = maxx is never true. |
Author: | the_short1 [ Wed Jun 09, 2004 9:22 pm ] |
Post subject: | |
ur still gona have problesm... cervants is right... but u will have to do more then just draw at maxx.... u will have to change the coords too... << dont think u had that in there.. if x1 >= maxx then x1 := maxx- incriment *that ur moving by... Pic.Draw (parameters) end if oterwise when u go to press LEFT ur guy's coords mite be WAY outa the screen and it will take a whgile for u to acuially MOVE the picture! hope that helps!! |
Author: | PuterFreak [ Thu Jun 10, 2004 6:30 pm ] |
Post subject: | |
Well, i tried both of your methods but still no luck, My program is a space invaders type of game on the x-axis. I guess i dont need boundaries but i think they are just a little extra. I appreciate ur attempt to help me ^_^ thanx |