Defend the school (lol) one click at a time
Author |
Message |
element4l
|
Posted: Tue Oct 16, 2007 4:45 pm Post subject: Defend the school (lol) one click at a time |
|
|
Ok. this is my final project for my Turing class. It's very early in development, but I need to get this fixed before moving on. As it is now, you can just hold your mouse button over the guys and they'll die (which would be cheating) They need to click 5 time individually to kill them. So basically, the soldiers run, you "kill" them and they go off screen and come back (supposedly as a different person). I'd also like to know if it would be possible to have more people at the same time on the screen without having to manually create them, like bot3, bot4 etc.
Turing: |
View.Set ("graphics:800;400,position:center;center,nobuttonbar,offscreenonly,title: Getting the day off")
var pos1 : int := 0
var pos2 : int := - 40
var pos3 : int := - 80
var up, up2, up3 : int := 0
var lvl, diff : int := 3
var speed1, speed2, speed3 : int := 1
var bot : int := 0
var cash : int := 100
var hits1, hits2, hits3 : int := 0
procedure bots
pos1 + = speed1
Pic.ScreenLoad ("bot1.bmp", pos1, up, picUnderMerge)
if pos1 >= 400 then
speed1 := 0
end if
end bots
procedure bots2
pos2 + = speed2
Pic.ScreenLoad ("bot2.bmp", pos2, up2, picUnderMerge)
if pos2 >= 405 then
speed2 := 0
end if
end bots2
procedure bots3
pos3 + = speed3
Pic.ScreenLoad ("bot3.bmp", pos3, up3, picUnderMerge)
if pos3 >= 410 then
speed3 := 0
end if
end bots3
procedure attack
var x, y, b : int
mousewhere (x, y, b )
if x >= pos1 and x <= pos1 + 21 and y >= up and y <= up + 29 and b = 1
then
hits1 + = 1
end if
if hits1 = 5 and x >= pos1 and x <= pos1 + 21 and y >= up and y <= up + 29 and b = 1 then
cash + = 9
pos1 :=- 90
hits1 := 0
end if
end attack
procedure attack2
var x, y, b : int
mousewhere (x, y, b )
if x >= pos2 and x <= pos2 + 21 and y >= up2 and y <= up2 + 29 and b = 1
then
hits2 + = 1
end if
if hits2 = 5 and x >= pos2 and x <= pos2 + 21 and y >= up2 and y <= up2 + 29 and b = 1 then
cash + = 9
pos2 :=- 130
hits2 := 0
end if
end attack2
procedure attack3
var x, y, b : int
mousewhere (x, y, b )
if x >= pos3 and x <= pos3 + 21 and y >= up3 and y <= up3 + 29 and b = 1
then
hits3 + = 1
end if
if hits3 = 5 and x >= pos3 and x <= pos3 + 21 and y >= up3 and y <= up3 + 29 and b = 1 then
cash + = 9
pos3 :=- 130
hits3 := 0
end if
end attack3
randint (up, 1, 30)
randint (up2, 1, 30)
randint (up3, 1, 30)
randint (speed1, 2, diff )
randint (speed2, 2, diff )
randint (speed3, 2, diff )
loop
Draw.Cls
put cash
bots
attack
bots2
attack2
bots3
attack3
Pic.ScreenLoad ("school.bmp", 0, 0, picUnderMerge)
View.Update
end loop
|
Description: |
|
Download |
Filename: |
game.zip |
Filesize: |
62.69 KB |
Downloaded: |
128 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Tue Oct 16, 2007 5:36 pm Post subject: Re: Defend the school (lol) one click at a time |
|
|
element4l @ Tue Oct 16, 2007 4:45 pm wrote: I'd also like to know if it would be possible to have more people at the same time on the screen without having to manually create them, like bot3, bot4 etc.
Absolutely. Whenever you find yourself making foo1, foo2, anything_number - chances are you should be using an Array instead.
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Martin
|
Posted: Tue Oct 16, 2007 5:54 pm Post subject: RE:Defend the school (lol) one click at a time |
|
|
For the clicking, you need to keep track of the state. There are really four different states that the moue can be in:
1. Up.
2. Being held down.
3. Being clicked.
4. Being released from a click.
Have something like:
code: |
% 0 is up, 1 is down
var last_state : int
last_state := 0
|
Then, when you click on somewhere, add a check like
code: |
if button_pressed = true and last_state = 0 then
%The button was up, so do damage
last_state = 1
else if button_pressed = false then
last_state = 0
end if |
|
|
|
|
|
|
element4l
|
Posted: Tue Oct 16, 2007 6:01 pm Post subject: RE:Defend the school (lol) one click at a time |
|
|
You are both Gods. Thank you
|
|
|
|
|
|
|
|