Need help making enemy disappear
Author |
Message |
Cuzty
|
Posted: Mon May 17, 2004 7:48 pm Post subject: Need help making enemy disappear |
|
|
I'm pretty newbie at this programming stuff so I've come here to see if any of you guys can help me out. I have this project due for my computer science class and I gotta make a game. I was wondering if you could help me make the enemy (the ball) disappear, or explode, when I shoot it. The collision is already detected but I just can't seem to make the darn thing go away . So if anyone can help me, it would be greatly appreciated .
code: | setscreen ("offscreenonly")
var nmepos, count, m, x, a, b, ymouse, xmouse, button : int
count := 0
%The Plane
procedure plane
drawline (xmouse - 4, 5, xmouse, 40, 4)
drawline (xmouse - 3, 5, xmouse, 40, 4)
drawline (xmouse - 2, 5, xmouse, 40, 4)
drawline (xmouse - 1, 5, xmouse, 40, 4)
drawline (xmouse, 5, xmouse, 40, 4)
drawline (xmouse + 1, 5, xmouse, 40, 4)
drawline (xmouse + 2, 5, xmouse, 40, 4)
drawline (xmouse + 3, 5, xmouse, 40, 4)
drawline (xmouse + 4, 5, xmouse, 40, 4)
end plane
%The falling ball
process nme
loop
randint (m, 10, maxx - 10)
for decreasing i : maxy .. 1 by 3
cls
drawfilloval (m, i, 10, 10, blue)
delay (10)
end for
end loop
end nme
%Your Plane
process you
loop
mousewhere (xmouse, ymouse, button)
cls
put count
plane
View.Update
%The Bullet
if button = 1 then
a := xmouse
b := ymouse
for i : 40 .. 400 by 5
mousewhere (xmouse, ymouse, button)
cls
plane
drawline (a - 1, i, a - 1, i + 40, 7)
drawline (a, i, a, i + 40, 7)
drawline (a + 1, i, a + 1, i + 40, 7)
%Collision Detection
if whatdotcolor (a, i + 41) = blue then
nmepos := i + 41
count := count + 1
elsif whatdotcolor (a, i + 42) = blue then
nmepos := i + 42
count := count + 1
elsif whatdotcolor (a, i + 43) = blue then
nmepos := i + 43
count := count + 1
elsif whatdotcolor (a, i + 44) = blue then
nmepos := i + 44
count := count + 1
elsif whatdotcolor (a - 1, i + 41) = blue then
nmepos := i + 41
count := count + 1
elsif whatdotcolour (a - 1, i + 42) = blue then
nmepos := i + 42
count := count + 1
elsif whatdotcolour (a - 1, i + 43) = blue then
nmepos := i + 43
count := count + 1
elsif whatdotcolour (a - 1, i + 44) = blue then
nmepos := i + 44
count := count + 1
elsif whatdotcolour (a + 1, i + 41) = blue then
nmepos := i + 41
count := count + 1
elsif whatdotcolour (a + 1, i + 42) = blue then
nmepos := i + 42
count := count + 1
elsif whatdotcolor (a + 1, i + 43) = blue then
nmepos := i + 43
count := count + 1
elsif whatdotcolor (a + 1, i + 44) = blue then
nmepos := i + 44
count := count + 1
end if
View.Update
end for
end if
end loop
end you
fork you
fork nme |
And I apologize for my crappy coding.. I'm not very good at this stuff .[/code] |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Paul
|
Posted: Mon May 17, 2004 8:16 pm Post subject: (No subject) |
|
|
well this kinda works...
code: |
setscreen ("offscreenonly")
var nmepos, count, m, x, a, b, ymouse, xmouse, button : int
count := 0
var check: boolean:= false
%The Plane
procedure plane
drawline (xmouse - 4, 5, xmouse, 40, 4)
drawline (xmouse - 3, 5, xmouse, 40, 4)
drawline (xmouse - 2, 5, xmouse, 40, 4)
drawline (xmouse - 1, 5, xmouse, 40, 4)
drawline (xmouse, 5, xmouse, 40, 4)
drawline (xmouse + 1, 5, xmouse, 40, 4)
drawline (xmouse + 2, 5, xmouse, 40, 4)
drawline (xmouse + 3, 5, xmouse, 40, 4)
drawline (xmouse + 4, 5, xmouse, 40, 4)
end plane
%The falling ball
process nme
check := false
loop
randint (m, 10, maxx - 10)
for decreasing i : maxy .. 1 by 3
cls
drawfilloval (m, i, 10, 10, blue)
delay (10)
if check = true then
drawfillstar (m-10, i-10, m+10, i+10, 12)
View.Update
delay (500)
exit
end if
end for
check := false
end loop
end nme
%Your Plane
process you
loop
mousewhere (xmouse, ymouse, button)
View.Update
cls
put count
plane
%The Bullet
if button = 1 then
a := xmouse
b := ymouse
for i : 40 .. 400 by 5
mousewhere (xmouse, ymouse, button)
cls
plane
drawline (a - 1, i, a - 1, i + 40, 7)
drawline (a, i, a, i + 40, 7)
drawline (a + 1, i, a + 1, i + 40, 7)
%Collision Detection
if xmouse > m-10 and xmouse < m+10 and button = 1 then
check := true
end if
View.Update
end for
end if
end loop
end you
fork you
fork nme
|
and its shorter than what u have, Im guessing there are errors due to the proecesses. if u look close enough, if the ball gets hit, it turns into a star. |
|
|
|
|
|
Cuzty
|
Posted: Mon May 17, 2004 8:51 pm Post subject: (No subject) |
|
|
I cannot describe to you how much I love you, Paul. |
|
|
|
|
|
|
|