LEVELS FOR A GAME!
Author |
Message |
benQ
|
Posted: Fri Jan 14, 2005 9:22 am Post subject: LEVELS FOR A GAME! |
|
|
Hey. I'm trying to make three levels for my blocksies game. I need to make a BABY, INTERMEDIATE, and ADVANCED levels. So here's my code so far. I'm just wondering after I get the input of the level from the user, how do i make it so that each choice takes you to a different program? Would i copy and paste the program 3 time for each if and elsif? Any help is appreciated.
code: |
put "Welcome to Blocksies! Use the <ARROW> keys to move the"
put "blocker."
put "Make sure the asterisk doesn't get past your blocker!"
var Choice : int
put "Please choose the level you wish to play."
put "1. BABY"
put "2. INTERMEDIATE"
put "3. ADVAMCED"
get Choice
if Choice=1 then
put "BABY"
elsif Choice=2 then
put "INTERMEDIATE"
elsif Choice=3 then
put "ADVANCED"
end if
cls
% This is a program that lets you use the arrow keys to control the blocker.%
% The object is to block ten asterisks.%
const BLOCKER :=
chr(220)+chr(220)+chr(220)+chr(220)+chr(220)
const WAIT := 125
const NUMBER_OF_ASTERISKS := 10
const LEFT_ARROW := chr(203)
const RIGHT_ARROW := chr(205)
const UP_ARROW := chr(200)
const DOWN_ARROW := chr(208)
const BLOCKER_ROW := 24
const BLANK_BLOCKER := " "
var Key : string (1)
var Asterisk_Column, Start, Finish : int
var Blocker_Column := 38
var Asterisk_Row := 2
setscreen ("noecho,nocursor")
procedure Move_Blocker
%We wait for the user to press a key.%
getch (Key)
%We erase a previously positioned blocker.%
locate (BLOCKER_ROW, Blocker_Column)
put BLANK_BLOCKER
%We adjust the position of the blocker%
%according to the direction specified%
%by the user.%
if Key = RIGHT_ARROW then
Blocker_Column := Blocker_Column + 2
elsif Key = LEFT_ARROW then
Blocker_Column := Blocker_Column - 2
elsif Key = UP_ARROW then
Blocker_Column := 2
elsif Key = DOWN_ARROW then
Blocker_Column := 75
end if
%We do not allow the blocker to be moved%
%Beyond the borders of the screen%
if Blocker_Column > 75 then
Blocker_Column := 75
elsif Blocker_Column < 2 then
Blocker_Column := 2
end if
%The blocker is displayed on the screen.%
locate (BLOCKER_ROW, Blocker_Column)
put BLOCKER
end Move_Blocker
locate (BLOCKER_ROW, Blocker_Column)
put BLOCKER
randomize
clock (Start)
for Asterisk : 1 .. NUMBER_OF_ASTERISKS
locate (1, 1)
put "Asterisk #", Asterisk
randint (Asterisk_Column,2,79)
loop
locate (Asterisk_Row, Asterisk_Column)
put "*"
delay (100)
if hasch then
Move_Blocker
end if
locate (Asterisk_Row, Asterisk_Column)
put " "
Asterisk_Row := Asterisk_Row + 1
if Asterisk_Row > 24 then
Asterisk_Row := 2
end if
if Asterisk_Column >= Blocker_Column and
Asterisk_Column <= Blocker_Column + 4 and
Asterisk_Row = 24 then
sound (100, 100)
exit
elsif Asterisk_Row=24 and
(Asterisk_Column<Blocker_Column or
Asterisk_Column>Blocker_Column+4) then
sound (100,100)
end if
end loop
end for
% After this for loop, the clock stops and the time is displayed.%
clock (Finish)
cls
put "Time: ", (Finish - Start) / 1000, " Seconds."
|
THANKS! |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Delos
|
Posted: Fri Jan 14, 2005 9:50 am Post subject: (No subject) |
|
|
All you need to do is define what destinguishes each level. For example, if during the 'Baby' stage, the object you're trying to click on (for example...I'm not positive what you're game does ) moves very slowly. In the 'Advanced' stage, the same object moves faster.
You could also change its size depending on the level.
To do this, you just need to define some vars at the beginning that will be changed depending on the User's selection of level...
e.g.
code: |
var speed : int
var input : string
var x, y : int := 100
put "Slow (1) or fast (2)?"
get input
if input = "1" then
speed := 15
elsif input = "2" then
speed := 10
else
speed := 0
end if
for i : 1..100
drawfilloval (x, y, 10, 10, 7)
x += 2
delay (speed)
end for
|
There you have it, a single proggie that runs differently depening on the input (level) chosen. |
|
|
|
|
|
benQ
|
Posted: Fri Jan 14, 2005 5:25 pm Post subject: Thanks |
|
|
Thanks so much! |
|
|
|
|
|
|
|