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

Username:   Password: 
 RegisterRegister   
 hit a key to remove picture
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
venue92




PostPosted: Tue Mar 31, 2009 1:34 pm   Post subject: hit a key to remove picture

Ok so i have objects (circles) falling down the screen, and i need it so that when i hit a specific key referring to a specific one of the circles, the circle disappears. i have no idea how to do this and any help will be greatly appreciated.


Turing:

setscreen ("graphics")

var q : int % difficulty variable
q:=0
procedure a
    %first circle

    var c : int

    c := Rand.Int (1, 6)

    for y : 10 .. 400
        drawfilloval (20 + (c * maxx div 7), 400 - y, 20, 20, brightblue)
        delay (q)
        drawfilloval (20 + (c * maxx div 7), 400 - y, 20, 20, white)
    end for
end a
procedure b
    %second circle

    var d : int

    d := Rand.Int (1, 6)

    for y : 10 .. 400
        drawfilloval (20 + (d * maxx div 7), 400 - y, 20, 20, black)
        delay (q)
        drawfilloval (20 + (d * maxx div 7), 400 - y, 20, 20, white)
    end for
end b

%third circle
procedure c
    var f : int

    f := Rand.Int (1, 6)

    for y : 10 .. 400
        drawfilloval (20 + (f * maxx div 7), 400 - y, 20, 20, purple)
        delay (q)
        drawfilloval (20 + (f * maxx div 7), 400 - y, 20, 20, white)
    end for
end c
%difficulty selection

procedure gui
    locatexy (110, 325)
    put "Easy"
    locatexy (110, 200)
    put "Medium"
    locatexy (110, 75)
    put "Hard"
    drawbox (50, 275, 175, 375, red)
    drawbox (50, 150, 175, 250, red)
    drawbox (50, 25, 175, 125, red)
end gui

var x, y, button : int
gui
loop
    mousewhere (x, y, button)
    if button = 1 and 50 <= x and x <= 175 and 275 <= y and y < 375 then
        q := 5
        cls
        a
        b
        c
    elsif button = 1 and 50 <= x and x <= 175 and 150 <= y and y <= 250 then
        q := 3
        cls
        a
        b
        c
    elsif button = 1 and 50 <= x and x <= 175 and 25 <= y and y <= 125 then
        q := 1
        cls
        a
        b
        c
end if
end loop
cls
Sponsor
Sponsor
Sponsor
sponsor
saltpro15




PostPosted: Tue Mar 31, 2009 2:43 pm   Post subject: RE:hit a key to remove picture

lol I assume this is some form of guitar hero-esque game? Well an easy way to do this is to use Input.KeyDown, then check if a certain key is being pressed.

example
Turing:

var chars : array char of boolean
loop
Input.KeyDown
if chars ("s") then
cls
end if
end loop


should be fairly straightforward
DemonWasp




PostPosted: Tue Mar 31, 2009 3:43 pm   Post subject: RE:hit a key to remove picture

The key is that you're not removing the picture, you're just not drawing it.

Starting from what saltpro15 has, it goes like this:

1. On every iteration through the loop, read all the input from the keyboard and determine which notes are still around and which aren't.
2. cls
3. Draw all of the notes that are still around and everything else for the game.
4. View.Update() to draw everything to the actual screen.

So in step 1, the note becomes inactive. In step 3, we draw without all inactive notes -> your note disappears!
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  [ 3 Posts ]
Jump to:   


Style:  
Search: