----------------------------------- BladeOfDeath Sun Dec 07, 2003 1:09 am Problem with graphics movement... ----------------------------------- I am currently using an if statement for my pacman's mouth. The variable is mthCls. mthCls increases by 10 each time through the loop, I need it so that once mthCls equals 30 that it will go down to 0 and when it reaches 0 it will go back up again. Could you please help, my assignment is due soon... ----------------------------------- Homer_simpson Sun Dec 07, 2003 1:23 am ----------------------------------- u mean something like this: loop for i : 1 .. 10 drawfilloval (320, 200, 100, i * 10, 12) delay (50) cls end for for decreasing i : 10 .. 1 drawfilloval (320, 200, 100, i * 10, 12) delay (50) cls end for end loop ----------------------------------- BladeOfDeath Sun Dec 07, 2003 2:16 am ----------------------------------- no i mean something like: mthCls:=0 --> mthCls:= 10 --> mthCls:=20 --> mthCls:=30 --> mthCls:=20 --> mthCls:=10 --> mthCls:=0 --> mthCls:=10 --> and repeats basically... if you can put that into an if statement i would really appreciate it... ----------------------------------- Tony Sun Dec 07, 2003 3:16 am ----------------------------------- well do what homer did with for loops. If you want it to look old-school like it used to be, you can add by 10, so that your forloops would increase/decrease by 10 instead. ----------------------------------- McKenzie Sun Dec 07, 2003 12:54 pm ----------------------------------- The only problem with the For loop is that if you want to move Pacman around you're out of luck (doesn't sound like he needs to.) I keeping with your original idea, I would use a second variable that will keep track of how much to add on to your mthCls variable each time around the loop. Kinda like: var mthChange:=10 loop mthCls += mthChange %mthCls := mthCls + mthChange if mthCls = 30 or mthCls = 0 then mthChange *= -1 end if end loop ----------------------------------- BladeOfDeath Sun Dec 07, 2003 4:14 pm ----------------------------------- Ill try that, I also have a problem with it being flashy... ----------------------------------- Tony Sun Dec 07, 2003 5:15 pm ----------------------------------- you have to use View.Update for animation not to flash. There's a tutorial on use of it available. ----------------------------------- BladeOfDeath Sun Dec 07, 2003 5:47 pm ----------------------------------- ok thanks for all your help everybody, I greatly appreciate it... ----------------------------------- BladeOfDeath Sun Dec 07, 2003 6:15 pm ----------------------------------- I tried the View.Update but it isnt working, ill upload the file... Oh by the way, I just started on it there are no levels. This is just the animations and dont change the random movements of the ghosts please... ----------------------------------- AsianSensation Sun Dec 07, 2003 6:52 pm ----------------------------------- are you using 4.0.x? you need the newest version of turing all patched to be able to use View.Update. another thing, try not to use process and fork, they are really really bad, almost as bad as whatdotcolor. ----------------------------------- BladeOfDeath Sun Dec 07, 2003 7:04 pm ----------------------------------- What else am i supposed to use? And i have 4.0.1p ----------------------------------- DanShadow Sun Dec 07, 2003 7:13 pm .. ----------------------------------- Or of course, you could do it 8th grader style! var pacman_x, pacman_y : int := 200 var mouth_draw_stage : int := 0 var mouth_move : string := "open" loop if mouth_draw_stage < 3 and mouth_move = "open" then Draw.FillBox (0, 0, maxx, maxy, 255) Draw.FillOval (pacman_x, pacman_y, 8, 8, 14) delay (300) Draw.Line (pacman_x, pacman_y, pacman_x - 2, pacman_y + 8, 255) Draw.Line (pacman_x, pacman_y, pacman_x + 2, pacman_y + 8, 255) Draw.Fill (pacman_x, pacman_y + 7, 255, 255) delay (300) Draw.Line (pacman_x, pacman_y, pacman_x - 6, pacman_y + 8, 255) Draw.Line (pacman_x, pacman_y, pacman_x + 6, pacman_y + 8, 255) Draw.Fill (pacman_x - 3, pacman_y + 6, 255, 255) Draw.Fill (pacman_x + 3, pacman_y + 7, 255, 255) delay (300) elsif mouth_draw_stage = 3 then Draw.FillBox (0, 0, maxx, maxy, 255) Draw.FillOval (pacman_x, pacman_y, 8, 8, 14) delay (300) Draw.Line (pacman_x, pacman_y, pacman_x + 2, pacman_y - 8, 255) Draw.Line (pacman_x, pacman_y, pacman_x - 2, pacman_y - 8, 255) Draw.Fill (pacman_x, pacman_y - 7, 255, 255) delay (300) Draw.Line (pacman_x, pacman_y, pacman_x + 6, pacman_y - 8, 255) Draw.Line (pacman_x, pacman_y, pacman_x - 6, pacman_y - 8, 255) Draw.Fill (pacman_x + 3, pacman_y - 6, 255, 255) Draw.Fill (pacman_x - 3, pacman_y - 7, 255, 255) delay (300) mouth_move := "close" end if if mouth_move = "close" then Draw.FillBox (0, 0, maxx, maxy, 255) Draw.FillOval (pacman_x, pacman_y, 8, 8, 14) delay (300) Draw.Line (pacman_x, pacman_y, pacman_x + 2, pacman_y - 8, 255) Draw.Line (pacman_x, pacman_y, pacman_x - 2, pacman_y - 8, 255) Draw.Fill (pacman_x, pacman_y - 7, 255, 255) delay (300) Draw.Line (pacman_x, pacman_y, pacman_x + 6, pacman_y - 8, 255) Draw.Line (pacman_x, pacman_y, pacman_x - 6, pacman_y - 8, 255) Draw.Fill (pacman_x + 3, pacman_y - 6, 255, 255) Draw.Fill (pacman_x - 3, pacman_y - 7, 255, 255) delay (300) end if if mouth_draw_stage = 1 then mouth_move := "open" end if %Main Program Under Here end loop ----------------------------------- BladeOfDeath Sun Dec 07, 2003 7:15 pm ----------------------------------- this is my ISU for comp sci, I take it very seriously... ----------------------------------- McKenzie Mon Dec 08, 2003 12:38 am ----------------------------------- AZN is right. Too much forkn' around is going to be the source of endless headaches. The biggest problem is that the movement between Pac and the ghosts is not synchronized. What you need to do is simulate the simultanious movement yourself. Your mainline should look something like:%pseudo code loop movePacMan % one increment moveAllGhosts % each ghost moves one increment checkInteractions % someone gets eaten? View.Update exit when allDone end loop Because you move each character a small increment before you update the scene, they are, in effect, moving simultaneously