Trying to make pacman turn directions
Author |
Message |
IshiggyDiggy
|
Posted: Tue Dec 11, 2012 10:29 am Post subject: Trying to make pacman turn directions |
|
|
What is it you are trying to achieve?
<Replace all the <> with your answers/code and remove the <>>
I'm trying to make pacman flip instead of staying in one direction
What is the problem you are having?
<Answer Here> I don't know how to make him turn
Here's my code
Turing: |
<Add your code here>
var Pacman : int := Pic.FileNew ("Untitled-2.bmp")
var chars : array char of boolean
var x1 : int := 1
var x2 : int := x1 + 10
var y1 : int := 1
var y2 : int := y1 + 10
var xv : real := 0
var yv : real := 0
var g : real := 1
var ground : boolean := true
setscreen ("graphics:540;600,offscreenonly,nobuttonbar,title:Player Movement Tutorial")
loop
Input.KeyDown (chars )
if chars ('w') and y2 < maxy and ground = true then
yv + = 8
end if
if chars ('a') and x1 > 0 then
xv - = 1
elsif chars ('d') and x2 < maxx then
xv + = 1
elsif chars (KEY_ESC) then
exit
end if
if y1 > 0 then
yv - = g
elsif y1 < 0 then
yv := 0
y1 := 0
end if
if xv > 0 then
xv - = 0. 5
elsif xv < 0 then
xv + = 0. 5
end if
if x1 < 0 then
x1 := 0
xv := 0
elsif x2 > maxx then
x1 := maxx - 10
xv := 0
end if
if y2 > maxy then
y1 := maxy - 10
yv := 0
end if
if y1 = 0 then
ground := true
else
ground := false
end if
x1 + = round (xv )
y1 + = round (yv )
x2 := x1 + 10
y2 := y1 + 10
Pic.Draw (Pacman,x1, y1, 0)
locate (1, 1)
View.Update
delay (10)
cls
end loop
|
Please specify what version of Turing you are using
<Answer Here>
4.1 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
IshiggyDiggy
|
Posted: Thu Dec 13, 2012 9:49 am Post subject: RE:Trying to make pacman turn directions |
|
|
bump |
|
|
|
|
|
Fortes
|
Posted: Thu Dec 13, 2012 9:53 am Post subject: Re: Trying to make pacman turn directions |
|
|
bump
|
|
|
|
|
|
|
|