Anyone know how to make a classic button masher Olympic game
Author |
Message |
born130
|
Posted: Mon May 12, 2003 9:28 pm Post subject: Anyone know how to make a classic button masher Olympic game |
|
|
Hey just wondering if anyone knows how to make a button masher Olympic game similar to arcade style.
For example: press "a" repeatedly to move character to finish line in 100m.
or long jump, get the right angle and button mash.
If anyone has code please post.
Thanks |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Mon May 12, 2003 9:37 pm Post subject: (No subject) |
|
|
i suppose you can just run a loop with a getch in it...
code: | var y:int := 0
var c:string(1)
loop
if hasch then
getch(c)
if c="a" then
y += 5
end if
end if
drawoval(100,y,3,3,red)
cls
end loop
|
*coughf2cough* - Darkness
then when time is up (ether you finished y>=maxy or time is up (use a timer)) then you exit the loop |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Dan
|
Posted: Mon May 12, 2003 9:37 pm Post subject: (No subject) |
|
|
here is a really really really simplified version of what you want to do:
code: |
var num:int:=0
var key:string(1)
loop
getch(key)
num+=1
put num
end loop
|
You can use getch to wait until a key is hit then after that move the object and add to the counter. although there may be a problem in that you could hold down a button.
Indented -Darkness |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
Dan
|
Posted: Mon May 12, 2003 9:38 pm Post subject: (No subject) |
|
|
dang you bet me to it tony, oh well your ex is better |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
Martin
|
Posted: Tue May 13, 2003 11:34 am Post subject: (No subject) |
|
|
If you want it to be a button masher, then you would have to do this.
code: |
var key : array char of boolean
var x : int := 10
var buttonDown : boolean := false
loop
Input.KeyDown (key)
if key (KEY_RIGHT_ARROW) then
if buttonDown = false then
buttonDown := true
Draw.FillOval (x, 100, 10, 10, white)
x += 10
Draw.FillOval (x, 100, 10, 10, black)
end if
end if
if not key (KEY_RIGHT_ARROW) then
buttonDown := false
end if
end loop
|
|
|
|
|
|
|
born130
|
Posted: Tue May 13, 2003 8:46 pm Post subject: (No subject) |
|
|
Does anyone know how I could stop the clock when one of the racers has crossed the finish line?
i.e. it will stop when one of the racers crosses the finish line at point y.
Also how would i modify the controls by using two keys and moving through alternate pressings?
Thanks |
|
|
|
|
|
Dan
|
Posted: Tue May 13, 2003 8:57 pm Post subject: (No subject) |
|
|
born130 wrote: Does anyone know how I could stop the clock when one of the racers has crossed the finish line?
i.e. it will stop when one of the racers crosses the finish line at point y.
do you mean stop a timer you have going or stop the loop?
code: |
loop
code to make guy run and bution stuff
exit when y > y postion of finsh line then
end loop
|
or
code: |
loop
code to make guy run and bution stuff
if y < y postion of finsh line then
code for clok/timer to increas
end loop
|
|
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
born130
|
Posted: Tue May 13, 2003 9:07 pm Post subject: (No subject) |
|
|
Actually what i meant was i wanted to stop the clock that is running to show the time that the racer finished in.
i.e. if it took 9906 milliseconds to finish the race, the clock would stop and read that. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Dan
|
Posted: Wed May 14, 2003 3:41 pm Post subject: (No subject) |
|
|
oic, this is what i whode do.
code: |
var starttime: int
var time: int := 0
%beging of ruing code
starttime := Time.Sec
loop
% code to make guys run and stuff
if y < yend then %y is the loaction of the runer
%yend if the loaction of the end
time := Time.sec - starttime
put time
end if
exit when y > yend
end loop
put "your time was ", time
|
|
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
|
|