[Thread Prev] [Thread Next]
I've been working on a pacman game for a school projects, there has been a few
problems. The
following is my code and the problems:
***
1. Towards the middle or end of the game, random announcements come up that
are in other non-
running procedures.
2. After choosing Play Again after the game has ended the following text is
shown in the
command center:
Showpointsbox(a text box) is already used in showpoints(a procedure)
Howevever in the same procedure I have already carefully remove showpointsbox
3. Microworlds also quits unexpectly
4. If you beat the first level and touch a ghost on the second the following
text appears"
setcountpoints in eatingpoints
I am not sure if this happens anywhere else because the game quits before I
can test it.
5. Sometimes when trying to play again it also says "No turtle detected for
glide"
All of these are connected to the play2 procedure***
to reset
cg
setbg 70
carefully [remove "background][]
newturtle "background
setpos [0 0]
setsh 9
st
carefully [remove "countpoints][]
carefully [remove "timerbox][]
end
to start_up
introscreen
presentationmode
end
to play
maze
reset
forever [steer]
makepacman
level1
storeit
setcountpoints 0
storetime
settimerbox 300
forever [time]
launch [eating]
lastdot
ghostchase
end
to storeit
newtext "countpoints [-360 -195][50 100]
end
to storetime
newtext "timerbox [319 200][50 30]
end
to time
settimerbox timerbox - 1 wait 10
if timerbox = 0 [time ]
end
to losetime
announce [Oops! Your time ran out. YOU LOSE!!]
getpoints
stopall
end
to steer
if key? [keypressed readchar]
end
to keypressed :key
pacman,
if or equal? ascii :key 37 equal? ascii :key 28[seth 270 fd 15 setsh 5 wait 3
setsh 6 wait 3]
if or equal? ascii :key 38 equal? ascii :key 30[seth 0 setsh 4 wait 3 setsh 3
wait 3 fd 15]
if or equal? ascii :key 39 equal? ascii :key 29[seth 90 setsh 1 wait 3 setsh 2
wait 3 fd 15]
if or equal? ascii :key 40 equal? ascii :key 31[seth 180 setsh 7 wait 3 setsh
8 wait 3 fd 15]
end
to makepacman
carefully [remove "pacman] []
newturtle "pacman
setpos [329 -155]
st
setsh 5
seth 270
end
to level1
carefully [remove "t1][]
carefully [remove "t2][]
carefully [remove "t3][]
carefully [remove "t4][]
carefully [remove "t5][]
carefully [remove "t6][]
carefully [remove "t7][]
carefully [remove "t8][]
carefully [remove "t9][]
carefully [remove "t10][]
carefully [remove "t11][]
carefully [remove "t12][]
carefully [remove "t13][]
carefully [remove "t14][]
carefully [remove "t15][]
carefully [remove "t16][]
carefully [remove "t17][]
carefully [remove "t18][]
carefully [remove "t19][]
carefully [remove "t20][]
carefully [remove "t21][]
carefully [remove "t22][]
carefully [remove "t23][]
carefully [remove "t24][]
carefully [remove "t25][]
newturtle "t1
setpos [144 -168]
setsh 10
setsize 20
st
newturtle "t2
setpos [30 -156]
setsh 10
setsize 20
st
newturtle "t3
setpos [313 -98]
setsh 10
setsize 20
st
newturtle "t4
setpos [117 -86]
setsh 10
setsize 20
st
newturtle "t5
setpos [-21 -68]
setsh 10
setsize 20
st
newturtle "t6
setpos [34 -7]
setsh 10
setsize 20
st
newturtle "t7
setpos [-112 -94]
setsh 10
setsize 20
st
newturtle "t8
setpos [-29 -166]
setsh 10
setsize 20
st
newturtle "t9
setpos [315 -15]
setsh 10
setsize 20
st
newturtle "t10
setpos [-269 -130]
setsh 10
setsize 20
st
newturtle "t11
setpos [-192 -170]
setsh 10
setsize 20
st
newturtle "t12
setpos [-199 -62]
setsh 10
setsize 20
st
newturtle "t13
setpos [-112 33]
setsh 10
setsize 20
st
newturtle "t14
setpos [-73 156]
setsh 10
setsize 20
st
newturtle "t15
setpos [90 106]
setsh 10
setsize 20
st
newturtle "t16
setpos [-23 58]
setsh 10
setsize 20
st
newturtle "t17
setpos [107 34]
setsh 10
setsize 20
st
newturtle "t18
setpos [164 -9]
setsh 10
setsize 20
st
newturtle "t19
setpos [300 19]
setsh 10
setsize 20
st
newturtle "t20
setpos [170 106]
setsh 10
setsize 20
st
newturtle "t21
setpos [242 164]
setsh 10
setsize 20
st
newturtle "t22
setpos [316 116]
setsh 10
setsize 20
st
newturtle "t23
setpos [-169 33]
setsh 10
setsize 20
st
newturtle "t24
setpos [-237 156]
setsh 10
setsize 20
st
newturtle "t25
setpos [-343 49]
setsh 10
setsize 20
st
pacman, inFront
end
to eating
when [touching? "pacman "t1] [eatingpoints t1, ht]
when [touching? "pacman "t2] [eatingpoints t2, ht]
when [touching? "pacman "t3] [eatingpoints t3, ht]
when [touching? "pacman "t4] [eatingpoints t4, ht]
when [touching? "pacman "t5] [eatingpoints t5, ht]
when [touching? "pacman "t6] [eatingpoints t6, ht]
when [touching? "pacman "t7] [eatingpoints t7, ht]
when [touching? "pacman "t8] [eatingpoints t8, ht]
when [touching? "pacman "t9] [eatingpoints t9, ht]
when [touching? "pacman "t10] [eatingpoints t10, ht]
when [touching? "pacman "t11] [eatingpoints t11, ht]
when [touching? "pacman "t12] [eatingpoints t12, ht]
when [touching? "pacman "t13] [eatingpoints t13, ht]
when [touching? "pacman "t14] [eatingpoints t14, ht]
when [touching? "pacman "t15] [eatingpoints t15, ht]
when [touching? "pacman "t16] [eatingpoints t16, ht]
when [touching? "pacman "t17] [eatingpoints t17, ht]
when [touching? "pacman "t18] [eatingpoints t18,
ht]
when [touching? "pacman "t19] [eatingpoints t19, ht]
when [touching? "pacman "t20] [eatingpoints t20, ht]
when [touching? "pacman "t21] [eatingpoints t21, ht]
when [touching? "pacman "t22] [eatingpoints t22, ht]
when [touching? "pacman "t23] [eatingpoints t23, ht]
when [touching? "pacman "t24] [eatingpoints t24, ht]
when [touching? "pacman "t25] [eatingpoints t25, ht]
when [touching? "pacman "background] [losingpoints]
when [touching? "pacman "ghost] [loseghost]
when [touching? "pacman "ghost2] [loseghost]
end
to eatingpoints
setcountpoints countpoints + 10
end
to lastdot
when [finsh? = "true] [finshlevel1]
end
to finsh?
if (get "t25 "visible?) = "false
[op "true]
end
to finshlevel1
getpoints
cancel [time]
cancel [steer]
cancel [ghostchase]
when [clipboard > 199][level2]
when [clipboard < 200][lose]
end
to level2
announce [Your scorce is high enough to go to level 2. This time your score
must be a least
225. Get ready!]
maze
reset2
pacman,
setpos [329 -155]
setsh 5
seth 270
st
forever [steer]
t1, st
t2, st
t3, st
t4, st
t5, st
t6, st
t7, st
t8, st
t9, st
t10, st
t11, st
t12, st
t13, st
t14, st
t15, st
t16, st
t17, st
t18, st
t19, st
t20, st
t21, st
t22, st
t23, st
t24, st
t25,
setpos [-343 49]
st
pacman, iNfront
storeit
setcountpoints 0
storetime
settimerbox 250
forever [time]
lastdot2
ghost2, st
end
to reset2
cg
setbg 70
background,
setpos [0 0]
setsh 9
st
carefully [remove "countpoints][]
carefully [remove "timerbox][]
end
to getpoints
countpoints,
top
select
eol
copy
showpoints clipboard
end
to showpoints :text.input
showpointspage
carefully [remove "showpointsbox][]
newtext "showpointsbox [-235 100][500 300]
setfontsize 40
print sentence [You have a score of:] :text.input
transparent "showpointsbox
end
to losingpoints
bk 10
setcountpoints countpoints - 5
end
to ghostchase
carefully [remove "ghost][]
newturtle "ghost
setshape 11
setsize 31
st
forever [seth random 360 glide 75 .5]
carefully [remove "ghost2][]
newturtle "ghost2
setshape 11
ht
forever [seth random 360 glide 75 .5]
end
to loseghost
announce [The ghost has caught you! YOU LOSE!!]
getpoints
playagain
end
to lose
announce [Your score is too low. You cannot move on to level 2. YOU LOSE!!!]
playagain
end
to lastdot2
when [finsh? = "true] [beginwin?]
end
to beginwin?
getpoints
cancel [time]
cancel [steer]
cancel [ghostchase]
when [clipboard > 224][win]
when [clipboard < 225][lose2]
end
to win
announce [YOU HAVE WON!!!]
playagain
end
to lose2
announce [Your score is too low. YOU LOSE!!!]
playagain
end
to playagain
playagainscreen
end
to play2
maze
reset2
pacman,
setpos [329 -155]
setsh 5
seth 270
st
forever [steer]
t1, st
t2, st
t3, st
t4, st
t5, st
t6, st
t7, st
t8, st
t9, st
t10, st
t11, st
t12, st
t13, st
t14, st
t15, st
t16, st
t17, st
t18, st
t19, st
t20, st
t21, st
t22, st
t23, st
t24, st
t25,
setpos [-343 49]
st
pacman, iNfront
storeit
setcountpoints 0
storetime
settimerbox 300
forever [time]
lastdot
end
Thanks!!
____________________________________________________________________________________
Sick sense of humor? Visit Yahoo! TV's
Comedy with an Edge to see what's on, when.
http://tv.yahoo.com/collections/222
Previous by thread:
Pong
Next by thread:
Re: pacman woes
To save an attachment to your computer, PC users should right-click (Mac users, click and hold the mouse button) on the link and then choose 'save target as' from the pop-up menu. A window will then pop up in which you can choose a location for the file.
|