DDR Problems
Author |
Message |
Savage Reindeer
|
Posted: Thu Apr 30, 2009 9:32 am Post subject: DDR Problems |
|
|
What is it you are trying to achieve?
I am about half a year into learning Turing. So I am relitively new. I am making a DDR game. My current goal is to have a block (called arrowup) move up the screen and assing a value of "perfect", "good", "bad" or "miss" to the variable ans. I also want the program to generate blocks (or arrows) in four columns.
What is the problem you are having?
I am having two problems.
1) The block moves up into the three areas. If you hold down the up arrow, the value of ans will change for as long as that arrow is held down. How do I have the game take whatever value it is when the arrow is pushed?
2) I have no idea how to generate the blocks. I thought I would use arrays, but beyond that I have no idea.
Describe what you have tried to solve this problem
As for problem one, I tried making a loop inside a loop, that exited when the up arrow was pressed. the only problem was that it got stuck in the loop (displaying a blank screen) until the up arrow was pressed and then continuing later.
Like I said before, I have no idea how to solve the second problem passed the fact that a should use arrays.
Post any relevant code
Turing: |
%********************************
%name block TIK-02 TIK-02 TIK-02 TIK-02 TIK-02
%name - Alex Boer
%date - April 30, 2009
%program description
% Like Dance Dance Revolution or Guitar Hero but on a keyboard
%*********************************
%
%
%*********************************
%Algorithm
%A set of instructions in order, used to pre-plan a program
%*********************************
%
%
%*********************************
%Variables Dictionary
%declare variable by name and type
%The location of perfect, good, and bad hits
var perfect_x1, perfect_x2, perfect_y1, perfect_y2 : int
var good_x1, good_x2, good_y1, good_y2 : int
var bad_x1, bad_x2, bad_y1, bad_y2 : int
%Values are assinged to the perfect locations
perfect_x1 := 0
perfect_x2 := maxx
perfect_y1 := 455
perfect_y2 := 395
%Values are assinged to the good locations
good_x1 := 0
good_x2 := maxx
good_y1 := 460
good_y2 := 385
%Values are assinged to the bad locations
bad_x1 := 0
bad_x2 := maxx
bad_y1 := 470
bad_y2 := 375
%Positions of the moving arrows
var arrowup_x1, arrowup_y1, arrowup_x2, arrowup_y2 : int
arrowup_x1 := 0
arrowup_y2 := 0
arrowup_x2 := 50
arrowup_y1 := 50
var chars : array char of boolean
var ans : string := " " %shows the user if he/she got a perfect, good, bad or missed hit
%*********************************
%
%
%*********************************
%Procedures/Subprograms/Subroutines
%do each seperatly in a block
%Decides if the user pressed the arrows in a perfect, good, bad or miss location
%<><><><>><><><><><><><><><><><><><><><><><><><><><><><><><><><><>DECIDES IF THE HIT WAS BAD, GOOD, OR PERFECT
function hit (chars : array char of boolean) : string
if arrowup_y1 < perfect_y1 and arrowup_y2 > perfect_y2 and chars (KEY_UP_ARROW) then
result "perfect"
elsif arrowup_y1 < good_y1 and arrowup_y2 > good_y2 and chars (KEY_UP_ARROW) then
result "Good!"
elsif arrowup_y1 < bad_y1 and arrowup_y2 > bad_y2 and chars (KEY_UP_ARROW) then
result "Bad"
elsif arrowup_y2 > bad_y1 or arrowup_y2 < bad_y2 and chars (KEY_UP_ARROW) then
result "miss"
else
result " "
end if
end hit
%<><><><>><><><><><><><><><><><><><><><><><><><><><><><><><><><><>DECIDES IF THE HIT WAS BAD, GOOD, OR PERFECT
proc determine
loop
Input.KeyDown (chars )
cls
locate (15, 40)
put ans
delay (2)
drawfillbox (arrowup_x1, arrowup_y1, arrowup_x2, arrowup_y2, blue) %arrow
drawbox (perfect_x1, perfect_y1, perfect_x2, perfect_y2, black) %...perfect hit
drawbox (good_x1, good_y1, good_x2, good_y2, blue) %................good hit
drawbox (bad_x1, bad_y1, bad_x2, bad_y2, red) %.....................bad hit
delay (3)
ans := hit (chars )
arrowup_y2 + = 1
arrowup_y1 + = 1
View.Update
end loop
end determine
%*********************************
%
%
%*********************************
%Mainline
%step by step enter the program
View.Set ("offscreenonly")
determine
locate (15, 40)
put ans
%*********************************
|
Please specify what version of Turing you are using
<Answer Here> |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Dusk Eagle

|
Posted: Thu Apr 30, 2009 9:36 pm Post subject: Re: DDR Problems |
|
|
Quote: 1) The block moves up into the three areas. If you hold down the up arrow, the value of ans will change for as long as that arrow is held down. How do I have the game take whatever value it is when the arrow is pushed?
Do you know Object Oriented Programming? If so, make a block class that contains a boolean variable stating whether an attempt has been made to make points off of that block. If an attempt has been made, disable all further attempts.
However, if you are not familiar with OOP, I suggest that once a button has been pushed, you set a variable that declares whether the button is up or down to down. Then, make them raise the key again before setting the variable back to up and allowing them to score from it. You can check that a key is up using
Turing: |
var chars : array char of boolean
Input.Keydown(chars)
if not chars('a') then
%'a' key is not down
|
Quote: I have no idea how to generate the blocks. I thought I would use arrays, but beyond that I have no idea.
Here's pseudo-code to help you develop your idea. I believe this should work.
code: |
if box > maxy then
box_y := 0
rand := Rand.Int(0,4)
box_x1 := rand * spacing_between_boxes + offset_from_left_of_screen
box_x2 := rand * spacing_between_boxes + offset_from_left_of_screen + length_of_box
Draw.Box(box_x1,box_y,box_x2,some_var,some_col)
box_y += 5 %moves box
end if
|
|
|
|
|
|
 |
copthesaint

|
Posted: Thu Apr 30, 2009 10:54 pm Post subject: RE:DDR Problems |
|
|
If you go here http://compsci.ca/v3/viewtopic.php?t=20842, I have a Key module that you may like to look at. I have made a key hit function that can solve problem 1, and problem 2 , you will need a couple arrays, and array 1 to 4 (assuming there are 4 arrows ) of the x, a variable for the velocity, an array for the max num of arrows for there y position and an array for the max num of arrows for the type. (if type 1 then draw at x (1)) If you need me to xplain more clearly I can help at any time. |
|
|
|
|
 |
Savage Reindeer
|
Posted: Fri May 01, 2009 8:30 am Post subject: RE:DDR Problems |
|
|
I am familiar with the concept of OOP, an object is like a car, and its properties are like its parts, and you can change the parts to make different types of cars, but they are still a car.
Anyway, could someone direct me to a tutorial for OOP? |
|
|
|
|
 |
Dusk Eagle

|
Posted: Fri May 01, 2009 9:58 am Post subject: Re: DDR Problems |
|
|
Check out The Turing Walkthrough. It includes extensive lessons in classes, as well as many other useful subjects. |
|
|
|
|
 |
Savage Reindeer
|
Posted: Fri May 01, 2009 2:58 pm Post subject: Re: DDR Problems |
|
|
I tried using nested if statements. It didn't seem to do anything.
Turing: |
function hit (chars : array char of boolean) : string
%If the top side of the box is below the top side of the perfect area
%and the bottom of box below the bottom of the perfect area
if boxup_y1 < perfect_y1 and boxup_y2 > perfect_y2 and chars (KEY_UP_ARROW) then
if not chars (KEY_UP_ARROW) then %If the up arrow is not pressed down
result "perfect"
end if
else %If the up button is never pressed
result " "
end if
%If the top side of the box is below the top side of the good area
%and the bottom of box below the bottom of the perfect area
if boxup_y1 < good_y1 and boxup_y2 > good_y2 and chars (KEY_UP_ARROW) then
if not chars (KEY_UP_ARROW) then %If the up arrow is not pressed down
result "Good!"
end if
else %If the up button is never pressed
result " "
end if
%If the top side of the box is below the top side of the bad area
%and the bottom of box below the bottom of the perfect area
if boxup_y1 < bad_y1 and boxup_y2 > bad_y2 and chars (KEY_UP_ARROW) then
if not chars (KEY_UP_ARROW) then %If the up arrow is not pressed down
result "Bad"
end if
else %If the up button is never pressed
result " "
end if
%If the box is not in any area
if boxup_y2 > bad_y1 or boxup_y2 < bad_y2 and chars (KEY_UP_ARROW) then
if not chars (KEY_UP_ARROW) then %If the up arrow is not pressed down
result "miss"
end if
else %If the up button is never pressed
result " "
end if
end hit
|
|
|
|
|
|
 |
BigBear
|
Posted: Fri May 01, 2009 3:55 pm Post subject: RE:DDR Problems |
|
|
Follow the order of your code in that function it will check the first if statement if it is true it will follow after the then
if it is false it will exit the function with the result " " |
|
|
|
|
 |
|
|