Computer Science Canada moving my scientist dude |
Author: | Hariss [ Sun Jan 21, 2007 9:44 pm ] |
Post subject: | moving my scientist dude |
hello this is my 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 i mnage to move the scientist around, but he keeps on walking, i need him to take one step!!! I also need someone to tell me how to do collision detection with pics and things like if i move my guy around and that he stays within the maze walls of my maze game. Thanx very much |
Author: | zedx_26 [ Sun Jan 21, 2007 10:02 pm ] |
Post subject: | Re: moving my scientist dude |
I would advice you to use key.inputdown rather the getch. I used getch first and had same problem. i edited your code a bit try if it works 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 var chars : array char of boolean Input.KeyDown (chars) % for a : 0 .. 1 % if hasch then % getch (input) % end if % if ord (input) = 205 then if chars ('i') 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 elsif chars ('e') 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 elsif chars ('a') 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 elsif chars ('d') 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 |
Author: | zedx_26 [ Sun Jan 21, 2007 10:04 pm ] |
Post subject: | RE:moving my scientist dude |
hey i changed the controls a bit and they are i,e,a,d. I know the controls are random but i put down any control i thoguht. you can switch it wit if chars (KEY_UP_ARROW) then and etc and for colision irecomend you to check collision tutorial in tutorial section. and tell me if this works for u good luck |
Author: | Hariss [ Sun Jan 21, 2007 11:35 pm ] |
Post subject: | Re: moving my scientist dude |
thanks for the help, but i get errors with the for statement. There is no for statement, and thats what i need, when i tried to add for a:0..1 then it worked, but my guy never appeared on the screen. |
Author: | agnivohneb [ Mon Jan 22, 2007 11:02 am ] | ||
Post subject: | Re: moving my scientist dude | ||
Had no images to test with but got some done.
Hope that helps |
Author: | Hariss [ Mon Jan 22, 2007 11:59 am ] |
Post subject: | Re: moving my scientist dude |
here is the code now setscreen ("graphics:300,200;nocursor;offscreenonly") var pic : int var bg_ground : int bg_ground := Pic.FileNew ("exterior.jpg") %Your bg name here var pic_right : array 0 .. 1 of string pic_right (0) := "scientist right.jpg" pic_right (1) := "scientist right step one.jpg" var pic_back : array 0 .. 1 of string pic_back (0) := "scientist back step two.jpg" pic_back (1) := "scientist back step one.jpg" var pic_front : array 0 .. 1 of string pic_front (0) := "scientist front step two.jpg" pic_front (1) := "scientist front step one.jpg" var pic_left : array 0 .. 1 of string pic_left (0) := "scientist left.jpg" pic_left (1) := "scientist left step one.jpg" var x, y : int := 100 var keydown : array char of boolean put "Press any key to begin" Input.Pause loop Input.KeyDown (keydown) for a : 0 .. 1 Pic.Draw (bg_ground, 0, 0, picMerge) if keydown (KEY_RIGHT_ARROW) then x := x + 2 pic := Pic.FileNew (pic_right (a mod 2)) Pic.Draw (pic, x, y, picMerge) elsif keydown (KEY_LEFT_ARROW) then x := x - 2 pic := Pic.FileNew (pic_left (a mod 2)) Pic.Draw (pic, x, y, picMerge) elsif keydown (KEY_UP_ARROW) then y := y + 2 pic := Pic.FileNew (pic_back (a mod 2)) Pic.Draw (pic, x, y, picMerge) elsif keydown (KEY_DOWN_ARROW) then y := y - 2 pic := Pic.FileNew (pic_front (a mod 2)) Pic.Draw (pic, x, y, picMerge) end if View.Update delay (60) cls end for end loop the input stuff is working, but everytime you let go of the arrow keys, then my guy dissapears. And when I draw my guy, white pixels appear around him......gotta fix help anyone? |
Author: | agnivohneb [ Mon Jan 22, 2007 2:28 pm ] |
Post subject: | Re: moving my scientist dude |
Post all your files (including images) in a zip archive (.zip) and upload it to this site. I will be able to help you more. |
Author: | zedx_26 [ Mon Jan 22, 2007 2:38 pm ] |
Post subject: | RE:moving my scientist dude |
ca u als post it as .t because i dont have winzip thanks |
Author: | Hariss [ Mon Jan 22, 2007 3:51 pm ] |
Post subject: | Re: moving my scientist dude |
ok, im planning on my guy going into the powerplant infront of him and going through rooms to find three pokemon. I have to make sure that he does not go off the screen. I fixed the previous errors so don't worry about it. just check it out, ill give you guys the stuff. |
Author: | agnivohneb [ Mon Jan 22, 2007 5:24 pm ] |
Post subject: | Re: moving my scientist dude |
OK I fixed you images they just needed to be in bmp and have the light light grey (very light) removed from around him (used win paint). I fixed the way he walks as well. The part inside the place is all yours. If it is for a school summative then you have to do at least 80%. I made my game and it was 99% mine. (1% friend helped with some math stuff.) |
Author: | Hariss [ Mon Jan 22, 2007 5:36 pm ] |
Post subject: | Re: moving my scientist dude |
can you post the stuff, thanks by the way do any of you know how to do collision detection with pictures??? |