Pacman...
Author |
Message |
florayu
|
Posted: Sat Nov 27, 2010 8:19 pm Post subject: Pacman... |
|
|
So , currently I am making a pacman game for my final project in Turing . I have set up the map , and all the boundaries when the user moves the pacman. However, with the setup of the map, i've placed the white dots as well, so as the pacman goes over the "dots", i draw over it with a black dot. But in that case, i also have my score increasing each time it moves in a certain direction while it draws the black dots . How can i do it so that it only increases the score when it colours over a white dot?
How my code looks like:
Turing: |
var tiles : array 0 .. 44, 0 .. 43 of int
var score : int := 0
var map : string := "map.txt"
var mapFile : int
open : mapFile, map, get
for decreasing y : 43 .. 0
for x : 0 .. 44
get : mapFile, tiles (x, y )
end for
end for
close (mapFile )
for x : 0 .. 44
for y : 0 .. 43
if tiles (x, y ) = 1 then
Draw.FillBox (x * 10, y * 10, x * 10 + 10, y * 10 + 10, red) % the +10 is there because each tile is 10 by 10
elsif tiles (x, y ) = 0 then
Draw.FillBox (x * 10, y * 10, x * 10 + 10, y * 10 + 10, black)
elsif tiles (x, y ) = 3 then
Draw.FillBox (x * 10, y * 10, x * 10 + 10, y * 10 + 10, black)
Draw.FillOval (x * 10, y * 10, 3, 3, white)
end if
end for
end for
var pacman : int := Sprite.New (Pic.Scale (Pic.FileNew ("pacman_eat.bmp"), 20, 20))
var pacmanMunch : int := Sprite.New (Pic.Scale (Pic.FileNew ("pacman_munch.bmp"), 20, 20))
var key : array char of boolean
var px, py : int := 2
put "SCORE:", score
loop
Input.KeyDown (key )
Sprite.SetPosition (pacman, px * 10, py * 10, true)
if key (KEY_LEFT_ARROW) and tiles (px - 1, py ) = 3 then
Draw.FillOval (px * 10, py * 10, 4, 4, black)
px - = 1
score + = 50
end if
% ETC ETC... (for the rest of the control keys)
Sprite.Show (pacman )
delay (130)
Sprite.Hide (pacman )
locate (1, 1)
put "SCORE:", score
end loop
|
% note that my map.txt looks something like :
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 3 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 3 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 3 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 3 3 3 3 3 3 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
TokenHerbz
|
Posted: Sat Nov 27, 2010 8:29 pm Post subject: RE:Pacman... |
|
|
first use your code tags so the code is easily readable in the post. UPDATE: THX:
Now, in the OP you stated your answer, so try to convert that into code and put that into your game.
if your score is adding more then you want it to, add more restrictions to it so that it ONLY adds when "CERTAINTY" happens.
what is tile 3 = food? You could add a boolean value and use that to tell you if you've eaten the food or not, and change that value depending on white/black dots. should be easy to add into it. |
|
|
|
|
|
|
|