Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 A DDR Clone, except not.
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Wolf_Destiny




PostPosted: Thu Feb 26, 2009 12:41 am   Post subject: A DDR Clone, except not.

Made a DDR style game, except it's not put to music, and the "steps" all move at different speeds. Run it and you'll see what I mean. It gets difficult pretty quickly, but starts off easy. Essentially you just press each arrow key when they are between the two green lines, and you get more points if it's closer to the center (indicated by a blue line.)
Anyways, here's the code if anyone wants to try it.
code:
procedure fade
View.Set ("offscreenonly,nobuttonbar,title:TGiC - By: Wolf_Destiny,graphics:400,400,position:center,center")

var font : int := Font.New ("Courier New:12")
var line1 : string := "   T.G.i.C.   "
var line2 : string := "By: Wolf_Destiny"
var line3 : string := "  }-Remake-{  "
var line4 : string := " V:0.0.4:Alpha "
for a : 1..length (line1)
Font.Draw (line1 (1..a),120,round (maxy/2),font,black)
View.Update
delay (100)
end for
for a : 1..length (line2)
Font.Draw (line2 (1..a),120,round (maxy/2)-20,font,black)
View.Update
delay (100)
end for
for a : 1..length (line3)
Font.Draw (line3 (1..a),120,round (maxy/2)-40,font,black)
View.Update
delay (100)
end for
for a : 1..length (line4)
Font.Draw (line4 (1..a),120,round (maxy/2)-80,font,black)
View.Update
delay (100)
end for
delay (1000)
for decreasing a : 31..16
drawfillbox (0,0,maxx,maxy,a)
Font.Draw (line1,120,round (maxy/2),font,black)
Font.Draw (line2,120,round (maxy/2)-20,font,black)
Font.Draw (line3,120,round (maxy/2)-40,font,black)
View.Update
delay (100)
end for
line1 := "  Get Ready!  "
for a : 1..length (line1)
Font.Draw (line1 (1..a),120,round (maxy/2),font,white)
View.Update
delay (100)
end for
delay (1000)
line2 := "3...2...1..."
for a : 1..length (line2)
Font.Draw (line2 (1..a),120,round (maxy/2)-20,font,white)
View.Update
delay (250)
end for
end fade
fade

View.Set ("offscreenonly,nobuttonbar,title:TGiC - By: Wolf_Destiny,graphics:400,max,position:center,center")

var Exit : boolean := false

procedure End_Game
Exit := true
end End_Game

var Upper : int := 300
var Lower : int := 100

var chars : array char of boolean
var Score : real := 0
var arrows : int := 25
var wall : int := 50
var size : int := 25
var minincr : int := 5
var maxincr : int := 25

var p : array 1.. arrows of record
_hit : boolean
_x : int
_y : real
_yvel : real
_dir : int
end record

procedure create (i : int, New : boolean)
p (i)._hit := false
p (i)._x := round (Rand.Int (wall,maxx-wall-size)/size)
p (i)._y := maxy+Rand.Int (100,1000)
if not New then
p (i)._yvel := p (i)._yvel + Rand.Int (minincr,maxincr)/100
else
p (i)._yvel := Rand.Int (1,5)/10
end if
p (i)._dir := Rand.Int (1,4)
end create

for a : 1..arrows
create (a,true)
end for

procedure draw_arrow (i : int, highlight : boolean)
drawfillbox (p (i)._x*size-size,round (p (i)._y),
    p (i)._x*size-1,round (p (i)._y)+size,p (i)._dir)
var ac : int := p (i)._dir + 8
if highlight then
ac := 0
end if
if p (i)._dir = 1 or p (i)._dir = 3 then
Draw.ThickLine (round (p (i)._x*size - size/2),round (p (i)._y + 4),
    round (p (i)._x*size - size/2),round (p (i)._y + size - 4), 3, ac)
else
Draw.ThickLine (round (p (i)._x*size - size + 4),round (p (i)._y + size/2),
    round (p (i)._x * size - 4),round (p (i)._y + size/2),3,ac)
end if
case p(i)._dir of
label 1:
Draw.ThickLine (round (p (i)._x*size - size+4),round (p (i)._y + size/2),
    round (p (i)._x*size - size/2),round (p (i)._y + size - 4), 3, ac)
Draw.ThickLine (round (p (i)._x*size - 4),round (p (i)._y + size/2),
    round (p (i)._x*size - size/2),round (p (i)._y + size - 4), 3, ac)
label 2:
Draw.ThickLine (round (p (i)._x*size - size/2),round (p (i)._y + size-4),
    round (p (i)._x * size - size + 4),round (p (i)._y + size/2),3,ac)
Draw.ThickLine (round (p (i)._x*size - size/2),round (p (i)._y + 4),
    round (p (i)._x * size - size + 4),round (p (i)._y + size/2),3,ac)
label 3:
Draw.ThickLine (round (p (i)._x*size - size+4),round (p (i)._y + size/2),
    round (p (i)._x*size - size/2),round (p (i)._y + 4), 3, ac)
Draw.ThickLine (round (p (i)._x*size - 4),round (p (i)._y + size/2),
    round (p (i)._x*size - size/2),round (p (i)._y + 4), 3, ac)
label 4:
Draw.ThickLine (round (p (i)._x*size - size/2),round (p (i)._y + size-4),
    round (p (i)._x * size - 4),round (p (i)._y + size/2),3,ac)
Draw.ThickLine (round (p (i)._x*size - size/2),round (p (i)._y + 4),
    round (p (i)._x * size - 4),round (p (i)._y + size/2),3,ac)
label :
end case
end draw_arrow

var Reset : array 1..4 of boolean := init (true,true,true,true,)
var Key_Hit : array 1..4 of boolean := init (false,false,false,false,)
var Keys : array 1..4 of char := init (
KEY_UP_ARROW,KEY_LEFT_ARROW,KEY_DOWN_ARROW,KEY_RIGHT_ARROW,)

procedure all_keys
for a : 1..4
exit when Exit
if ~chars (Keys (a)) then
Reset (a) := true
Key_Hit (a) := false
end if
exit when Exit
end for
end all_keys

procedure check_keys (i : int)
for a : 1..4
exit when Exit
if chars (Keys (a)) and Reset (a) and p (i)._dir = a then
Key_Hit (a) := true
Reset (a) := false
p (i)._hit := true
exit
end if
exit when Exit
end for
end check_keys

procedure varify
for a : 1..4
exit when Exit
if chars (Keys (a)) and ~Key_Hit (a) then
End_Game
end if
exit when Exit
end for
end varify

procedure score (y : real)
Score += (((Upper - Lower)/2)-abs(((Upper+Lower)/2)-y))*2
end score

var Lowest : array 1..4 of record
_y : real
_i : int
end record
Lowest (1)._y := 9999
Lowest (2)._y := 9999
Lowest (3)._y := 9999
Lowest (4)._y := 9999

procedure move_arrow (i : int)
if p (i)._hit then
score (p (i)._y + size/2)
create (i,false)
else
p (i)._y -= p (i)._yvel
if p (i)._y < -size-5 then
create (i,false)
End_Game
elsif p (i)._y + size >= Lower and p (i)._y <= Upper then
draw_arrow (i,true)
/*check_keys (i)*/
if p (i)._y < Lowest (p (i)._dir)._y then
Lowest (p (i)._dir)._y := p (i)._y
Lowest (p (i)._dir)._i := i
end if
else
draw_arrow (i,false)
end if
end if
end move_arrow

procedure update
Input.KeyDown (chars)
all_keys
for a : 1..arrows
move_arrow (a)
end for
for a : 1..4
if Lowest (a)._y not= 9999 then
check_keys (Lowest (a)._i)
Lowest (a)._y := 9999
end if
end for
varify
drawline (0,Upper,maxx,Upper,2)
drawline (0,round ((Upper+Lower)/2),maxx,round ((Upper+Lower)/2),1)
drawline (0,Lower,maxx,Lower,2)
end update

loop
exit when Exit
update
locate (1,1)
put "Score: ", round (Score)
View.Update
Time.DelaySinceLast (5)
exit when Exit
cls
end loop

Anyways, comments? Ideas/Improvements?
Sponsor
Sponsor
Sponsor
sponsor
Zren




PostPosted: Thu Feb 26, 2009 3:43 am   Post subject: Re: A DDR Clone, except not.

It freezes if I press the wrong button or two at once or something...
trevorprella




PostPosted: Thu Feb 26, 2009 7:28 pm   Post subject: Re: A DDR Clone, except not.

How did you fade the screen at the title? It was cool.
andrew.




PostPosted: Thu Feb 26, 2009 7:59 pm   Post subject: Re: A DDR Clone, except not.

Zren @ Thu Feb 26, 2009 3:43 am wrote:
It freezes if I press the wrong button or two at once or something...
What do you mean? It doesn't happen to me. The game finishes execution when you press the wrong button. Maybe that's what's happening to you.
tenniscrazy




PostPosted: Fri Feb 27, 2009 9:45 am   Post subject: Re: A DDR Clone, except not.

yeah, that kinda sucks you have to do it perfect to not loose, but i guess if it wasn't like that you could just button mash

trevorprella @ Thu Feb 26, 2009 6:28 pm wrote:
How did you fade the screen at the title? It was cool.


i have a fading effect in one of my programs

you just use Pic.DrawSpecial

and add in (p1, 10, 200, picCopy, picFadeIn, 1000) the picFadeIn part
Lekegolo killer




PostPosted: Mon Mar 02, 2009 11:48 am   Post subject: RE:A DDR Clone, except not.

Great, now i am addicted to 5 things Sad

highscore:9000 and sumthing
BigBear




PostPosted: Tue Mar 03, 2009 5:05 pm   Post subject: RE:A DDR Clone, except not.

OK I didn't understand why you had to be perfect but it allows to hit them in any order between the 3 lines.

Actually not bad game.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: