dodge ball
Author |
Message |
endusto
|
Posted: Thu Apr 13, 2006 4:49 pm Post subject: dodge ball |
|
|
heres my dodge ball game. just made it for fun
code: | % Dodge Ball Game
% Created by Andrew Cowan
% DECLARE THE VARIABLES
% w1 and w2 are useless in the game, they are just used so Mouse.Where wont give an error because we dont need
% x and y values for this game
var enemyx, w1, w2, button, count, count2, level : int
var enemyy : array 1 .. 100 of int % used to store the y axis for all enemies
enemyx := maxx % makes the enemys start at the right side of the window
var chars : array char of boolean % used with Input.KeyDown
count := 0
count2 := 1
enemyy (1) := 50
var y : int
y := maxy - 50
level := 1
setscreen ("offscreenonly") % takes us into graphics mode
loop
put
"Welcome to Dodge Ball! To move up, hold down any mouse button. To go\ndown release all mouse buttons.\n\nWays to die:\n1. Go too high.\n2. Go too low.\n3. Get hit.\n\nTo pause the game press P.\n\nPress any key to continue"
cls
exit when hasch % exits the loop when any key is pressed
end loop
loop
put "Level: ", level
% check if they want to pause...
Input.KeyDown (chars)
if chars ('p') then
loop
locate (12, 27)
put "Press any key to unpause."
exit when hasch
View.Update
end loop
end if
Mouse.Where (w2, w1, button)
for i : 1 .. count2
Draw.FillOval (enemyx, enemyy (i), 10, 10, green)
end for
if y <= -5 or y >= maxy + 5 or whatdotcolor (60, y) = green or whatdotcolor (50, y) = blue or whatdotcolor (60, y + 5) = green or whatdotcolor (60, y - 5) = green or whatdotcolor (50, y + 5) =
green or whatdotcolor (50, y - 5) = green then
cls
locate (12, 23)
put "You have died. Please play again."
exit when hasch
View.Update
exit
end if
% The player's controls
if button = 1 then
y += 2
else
y -= 2
end if
Draw.FillOval (50, y, 10, 10, red)
% Enemys
if count >= 800 then
level += 1
enemyx := maxx
count := 0
for i : 1 .. level
randint (enemyy (i), 10, maxy)
end for
count2 += 1
end if
View.Update
delay (6)
cls
count += 1
enemyx -= 1
end loop
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Clayton
|
Posted: Fri Apr 14, 2006 6:07 pm Post subject: (No subject) |
|
|
not bad although you should do something about randomizing the position of your "balls" so that they dont all go in a line, make it so that they are at different x coordinates, also you should make sure that the balls dont overlap, on level 8 i had like one big ass ball coming at me b/c they had all overlapped not bad though, collision detection leaves something to be desired though but good job |
|
|
|
|
|
Andy
|
Posted: Mon Apr 17, 2006 9:42 am Post subject: (No subject) |
|
|
ball? huh? where? |
|
|
|
|
|
NikG
|
Posted: Wed Apr 19, 2006 9:44 am Post subject: (No subject) |
|
|
endusto, insert a View.Update before the cls in your first loop so that we can see the intro screen.
2 possible improvements:
- Add a randomizer for both the speed of the ball (game was too slow for me) and for the start location of the ball.
- I didn't test your collision detection but looking at your code, I think it can be improved. Maybe run a loop for each enemy ball and check the balls distance from your ball's distance (Math.Distance(x1,y1,x2,y2)<=ballRadius*2)
Overall, not a bad start if you're planning to build on it. |
|
|
|
|
|
BenLi
|
Posted: Sun Apr 30, 2006 4:51 pm Post subject: (No subject) |
|
|
volcano run, quite fun, maybe graphics are in order, a helicopter or something like that |
|
|
|
|
|
ohgeez_
|
Posted: Mon May 08, 2006 8:49 pm Post subject: (No subject) |
|
|
for this. i strong suggest u to speed the balls coming toward u to go faster. its a little slow for any fun right now.
gj on ur collision detector, it seems really good
and as the other dude said. avoid the overlapping of the balls
and perhaps make it some that u can actually win the game
otherwise.. good start. and a good game =D |
|
|
|
|
|
|
|