Computer Science Canada need help with moving sprites |
Author: | Hariss [ Sat Jan 20, 2007 4:11 pm ] |
Post subject: | need help with moving sprites |
hello i have a summative due soon, its worth 30% of my mark and its due on tuesday. Can someone tell me how to move pic/sprties so they look like theyr walking and not just one pic that is still when it moves. I am a complete nub at this. ![]() |
Author: | BenLi [ Sat Jan 20, 2007 4:34 pm ] |
Post subject: | RE:need help with moving sprites |
why don't you post the sprites you want to use and the code that you've got |
Author: | agnivohneb [ Sun Jan 21, 2007 12:45 am ] |
Post subject: | Re: need help with moving sprites |
My friend made a Mario game and he had the same problem. I first told him he needed each image of Mario walking. ![]() Next he had to create a procedure for when Mario is walking (just a loop). then he had to define when mario was walking (run procedure) and when he was not (display still image of Mario standing). I hope you understand. BenLi wrote: why don't you post the sprites you want to use and the code that you've got
It is a good idea to post any problem programs (if there are more than 1 file use zip). That way people can help you faster. |
Author: | Clayton [ Sun Jan 21, 2007 1:00 am ] |
Post subject: | Re: need help with moving sprites |
what version of Turing are you using? if you are using 4.1, there is a Sprite. module that you can use. Although I have never personally used it myself, there is a tutorial in the [Turing Tutorials] on the Sprite module. If you are not using 4.1 however, you will have to do it manually. meaning importing each frame of mario (or whomever) running as a jpg, then running a control procedure to draw the appropriate picture. |
Author: | Robert [ Sun Jan 21, 2007 10:03 am ] |
Post subject: | RE:need help with moving sprites |
In the most recent version of Turing there is a command called "Pic.FileNewFrames" that you can use to load an animated gif. The Sprite module will probobally make actually drawing the frames a bit easier though. |
Author: | Hariss [ Sun Jan 21, 2007 9:40 pm ] |
Post subject: | RE:need help with moving sprites |
here is the code setscreen ("graphics:300,200") setscreen ("nocursor") setscreen ("offscreenonly") var pic, picground : int picground := Pic.FileNew ("exterior.jpg") var picfile_right_step : array 0 .. 1 of string picfile_right_step (0) := "scientist right.jpg" picfile_right_step (1) := "scientist right step one.jpg" var picfile_back_step : array 0 .. 1 of string picfile_back_step (0) := "scientist back step two.jpg" picfile_back_step (1) := "scientist back step one.jpg" var picfile_front_step : array 0 .. 1 of string picfile_front_step (0) := "scientist front step two.jpg" picfile_front_step (1) := "scientist front step one.jpg" var picfile_left_step : array 0 .. 1 of string picfile_left_step (0) := "scientist left.jpg" picfile_left_step (1) := "scientist left step one.jpg" var x, y : int := 100 var input : string (1) getch (input) loop for a : 0 .. 1 if hasch then getch (input) end if if ord (input) = 205 then Pic.Draw (picground, 0, 0, 1) x := x + 2 pic := Pic.FileNew (picfile_right_step (a mod 2)) View.Update delay (60) cls Pic.Draw (pic, x, y, 2) elsif ord (input) = 203 then Pic.Draw (picground, 0, 0, 1) x := x - 2 pic := Pic.FileNew (picfile_left_step (a mod 2)) View.Update delay (60) cls Pic.Draw (pic, x, y, 2) elsif ord (input) = 200 then Pic.Draw (picground, 0, 0, 1) y := y + 2 pic := Pic.FileNew (picfile_back_step (a mod 2)) View.Update delay (60) cls Pic.Draw (pic, x, y, 2) elsif ord (input) = 208 then Pic.Draw (picground, 0, 0, 1) y := y - 2 pic := Pic.FileNew (picfile_front_step (a mod 2)) View.Update delay (60) cls Pic.Draw (pic, x, y, 2) end if end for end loop |