Getting Pacman to change direction.. please help asap
Author |
Message |
acc_minion
|
Posted: Tue Jan 20, 2004 5:55 pm Post subject: Getting Pacman to change direction.. please help asap |
|
|
Okay the code i have now
( code: | var fast : int := 1
setscreen
("graphics:580;650,nobuttonbar,position:center,center,offscreenonly")
colorback (black)
cls
color (white)
%%%%%%%%%%%%
var score : int := 0
var text : int
var x2, y2 : int := 0
var dx2, dy2 : int := 1
var x, y : int := 120
var ch : array char of boolean
var tm, bm, dift, difb : int
%%%%%%%%%%%%%%%%
tm := 29
bm := 330
dift := -1
difb := 1
loop
%% End Time Commands %%
% Draw Pacman w/ mouth moving
Draw.FillArc (x, y, 14, 14, tm, bm, 14)
tm := tm + dift
bm := bm + difb
if tm = 1 then
dift := dift * -1
difb := difb * -1
elsif tm = 30 then
dift := dift * -1
difb := difb * -1
end if
% Pacman replacement code
if x = -15 then
x := maxx
elsif x = maxx + 15 then
x := -15
end if
%Pacman Move Code
Input.KeyDown (ch)
if ch ('8') and whatdotcolor (x, y + 18) not= 1 then
y := y + fast
elsif ch ('2') and whatdotcolor (x, y - 18) not= 1 then
y := y - fast
elsif ch ('4') and whatdotcolor (x - 18, y) not= 1 then
x := x - fast
elsif ch ('6') and whatdotcolor (x + 18, y) not= 1 then
x := x + fast
end if
View.Update
Draw.FillOval (x, y, 15, 15, black) %draws black oval around pacman
end loop
| )
As you see has some problems, at school the leaving of yellow crap isnt there, how ever wht I want to know is how to make hime change directions so if you press up he faces up. I know it is simple but time constraints are keeping me from doing this. Please help. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Cervantes
|
Posted: Tue Jan 20, 2004 6:12 pm Post subject: (No subject) |
|
|
you have to use Pic.Rotate
bring out the help file!! |
|
|
|
|
|
acc_minion
|
Posted: Wed Jan 21, 2004 6:13 pm Post subject: (No subject) |
|
|
yes but it donst help me in implementing it, if you lok at the code fron the help and the code im using, I have no idea what i am doing |
|
|
|
|
|
Cervantes
|
Posted: Thu Jan 22, 2004 6:56 pm Post subject: (No subject) |
|
|
first you have to make pacman into a variable by using Pic.New
%draw pacman here
var pacman : int := Pic.New (x1,y1,x2,y2)
cls
if you want him with the mouth moving you have to use case...
looks like this
code: | case pic_number of;
label 1 :
Pic.Draw (pic1, x, y, picMerge)
pic_number := 2
label 2 :
Pic.Draw (pic2, x, y, picMerge)
pic_number := 3
label 3 :
Pic.Draw (pic3, x, y, picMerge)
pic_number := 1
label :
end case |
hope this helps |
|
|
|
|
|
DanShadow
|
Posted: Thu Jan 22, 2004 10:40 pm Post subject: (No subject) |
|
|
or easier yet:
(with four different pics of him in different directions)
code: |
var key,direction:string(1):=""
%......
if key=(KEY_UP_ARROW) then
direction:="n"
elsif key=(KEY_DOWN_ARROW) then
direction:="s"
elsif key=(KEY_RIGHT_ARROW) then
direction:="e"
elsif key=(KEY_LEFT_ARROW) then
direction:="w"
end if
if direction="n" then
Pic.Draw(pac-north,pacx,pacy,picMerge)
elsif direction="s" then
Pic.Draw(pac-south,pacx,pacy,picMerge)
elsif direction="e" then
Pic.Draw(pac-east,pacx,pacy,picMerge)
elsif direction="w" then
Pic.Draw(pac-west,pacx,pacy,picMerge)
end if
|
|
|
|
|
|
|
Cervantes
|
Posted: Fri Jan 23, 2004 2:02 pm Post subject: (No subject) |
|
|
except with that his mouth isn't moving.... |
|
|
|
|
|
|
|