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

Username:   Password: 
 RegisterRegister   
 URGENT Help with guitarhero esque game; a few errors and problems.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
inmaid23




PostPosted: Fri Jan 20, 2012 12:40 pm   Post subject: URGENT Help with guitarhero esque game; a few errors and problems.

What is it you are trying to achieve?
<Reduce flickering, turn buttons green when you click the corresponding key in the specified area, have the buttons continuously fall in a randomized area.>


What is the problem you are having?
<None of what we have tried seems to work. We are Grade.10 turing students and are having trouble as this is our first game>


Describe what you have tried to solve this problem
<View.Set... Random.Int... if/when/then statements...>


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


<%Height and Width + B/G colour of Screen
setscreen ("graphics:max;max,nobuttonbar")
colourback (black)
cls

%Variables
var chars : array char of boolean %Needed for the input of the keys.
var x, y, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6 : int %X = Coordinates for falling ovals.

var picA : int  %P/Button A
var picS : int  %P/Button S
var picD : int  %P/Button D
var picJ : int  %P/Button J
var picK : int  %P/Button K
var picL : int  %P/Button L
var nokey : int %Picture 'X' or Fail.

picA := Pic.FileNew ("keya.jpg")
picS := Pic.FileNew ("keys.jpg")
picD := Pic.FileNew ("keyd.jpg")
picJ := Pic.FileNew ("keyj.jpg")
picK := Pic.FileNew ("keyk.jpg")
picL := Pic.FileNew ("keyl.jpg")
nokey := Pic.FileNew ("nokey.jpg")

%At what coordinates each button will start.

%A--------
x := 157   
y := 800
%S--------
x2 := 337 
y2 := 800
%D--------
x3 := 512 
y3 := 800
%J--------
x4 := 687 
y4 := 800
%K--------
x5 := 863 
y5 := 800
%L--------
x6 := 1039
y6 := 800

loop
    locatexy (320, 700)
    colour (white)
    put "Press the ASD JKL keys. *Note you can press multiple keys at once."

    x := x + 0
    y := y - 3
    x2 := x2 + 0
    y2 := y2 - 3
    x3 := x3 + 0
    y3 := y3 - 3
    x4 := x4 + 0
    y4 := y4 - 3
    x5 := x5 + 0
    y5 := y5 - 3
    x6 := x6 + 0
    y6 := y6 - 3

    Input.KeyDown (chars)
    for i : 1 .. 20 by 5

        if chars ('a') then
            Draw.Oval (180, 274, 20 + i, 20 + i, green + i)
            Draw.Dot (167 + Rand.Int (0, 30), 264 + Rand.Int (0, 30), brightgreen)
        end if
        if chars ('s') then
            Draw.Oval (360, 274, 20 + i, 20 + i, green + i)
            Draw.Dot (347 + Rand.Int (0, 30), 264 + Rand.Int (0, 30), brightgreen)
        end if
        if chars ('d') then
            Draw.Oval (535, 274, 20 + i, 20 + i, green + i)
            Draw.Dot (522 + Rand.Int (0, 30), 264 + Rand.Int (0, 30), brightgreen)
        end if
        if chars ('j') then
            Draw.Oval (710, 274, 20 + i, 20 + i, green + i)
            Draw.Dot (697 + Rand.Int (0, 30), 264 + Rand.Int (0, 30), brightgreen)
        end if
        if chars ('k') then
            Draw.Oval (885, 274, 20 + i, 20 + i, green + i)
            Draw.Dot (872 + Rand.Int (0, 30), 264 + Rand.Int (0, 30), brightgreen)
        end if
        if chars ('l') then
            Draw.Oval (1060, 274, 20 + i, 20 + i, green + i)
            Draw.Dot (1047 + Rand.Int (0, 30), 264 + Rand.Int (0, 30), brightgreen)
        end if
    end for

    Pic.Draw (picA, x, y, picCopy)
    if (y < 200) then
        Pic.Draw (nokey, x, y, picCopy)
    end if

    Pic.Draw (picS, x2, y2, picCopy)
    if (y < 200) then
        Pic.Draw (nokey, x2, y2, picCopy)
    end if

    Pic.Draw (picD, x3, y3, picCopy)
    if (y < 200) then
        Pic.Draw (nokey, x3, y3, picCopy)
    end if

    Pic.Draw (picJ, x4, y4, picCopy)
    if (y < 200) then
        Pic.Draw (nokey, x4, y4, picCopy)
    end if

    Pic.Draw (picK, x5, y5, picCopy)
    if (y < 200) then
        Pic.Draw (nokey, x5, y5, picCopy)
    end if

    Pic.Draw (picL, x6, y6, picMerge)
    if (y < 200) then
        Pic.Draw (nokey, x6, y6, picCopy)
    end if

    %<-------------------------------------------------------->
    Draw.ThickLine (0, 250, 1270, 250, 5, green)
    Draw.ThickLine (0, 250, 1270, 250, 5, green)
    Draw.ThickLine (0, 300, 1270, 300, 5, white)
    Draw.ThickLine (0, 300, 1270, 300, 5, white)
    delay (10)
    cls
    Draw.ThickLine (0, 250, 1270, 250, 5, green)
    Draw.ThickLine (0, 250, 1270, 250, 5, green)
    Draw.ThickLine (0, 300, 1270, 300, 5, white)
    Draw.ThickLine (0, 300, 1270, 300, 5, white)
end loop


>



Please specify what version of Turing you are using
<4.1.1>
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Fri Jan 20, 2012 12:55 pm   Post subject: RE:URGENT Help with guitarhero esque game; a few errors and problems.

Read up on View.Update() in the documentation to stop flickering. If you don't understand it fully after reading, there is a tutorial in the Turing Walkthrough that explains it.

As for the buttons- you never seem to draw them in any color but green.

You should be using an array to store the ovals. The size of the array should be equal to the maximum number of ovals that can be on the screen at a time.

I assume the ovals fall vertically. Therefore you need to choose an appropriate X value. Once you pick an X value, it should not change until the oval expires (reaches the bottom of the screen).
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: