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

Username:   Password: 
 RegisterRegister   
 Bullet in turing game is being weird. No idea how to fix, help needed badly.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
chimerix




PostPosted: Wed Nov 25, 2009 5:22 pm   Post subject: Bullet in turing game is being weird. No idea how to fix, help needed badly.

What is it you are trying to achieve?
Im trying to make a space invaders type game, however i cant get my bullet to work properly.

What is the problem you are having?
The bullet will not go in a straight line, and will not be refreshed. The red box is you, and the black box is the enemy (ignore). Movement are the arrow keys, and space is shoot.


Describe what you have tried to solve this problem
The program is (horribly) written by me already, but i just need the bullet to work.


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

Turing:

View.Set ("graphics:300;450,nobuttonbar")

const KEY_SPACE : char := chr (32)

var x, y, xx, yy, bullety : int
var a : int := 0

x := 10
y := 10
yy := 0
bullety := 10

procedure attacker
    if yy <= 0 then
        yy := 450
        randint (xx, 1, 30)
        xx := xx * 10
    end if
end attacker

procedure bullet
    if bullety >= 449 then
        bullety := 10
    end if
end bullet

loop
    attacker
    bullet
    yy := yy - 10
    bullety := bullety + 10
    var keys : array char of boolean
    Input.KeyDown (keys)
    drawfillbox (x, y, x + 10, y + 10, black)
    drawfillbox (xx, yy, xx + 10, yy + 10, red)
    drawfillbox (xx, yy + 10, xx + 10, yy + 20, white)
    if a = -10 then
        drawfillbox (x + 10, y, x + 20, y + 10, white)
    elsif a = 10 then
        drawfillbox (x - 10, y, x, y + 10, white)
    end if
    if keys (KEY_LEFT_ARROW) then
        a := -10
        x := x + a
    end if
    if keys (KEY_RIGHT_ARROW) then
        a := 10
        x := x + a
    end if
    if keys (KEY_SPACE) then
       
        drawfilloval (x , bullety + 10, 2, 2, black)
         drawfilloval (x , bullety + 9, 2, 2, black)
    end if
    delay (100)
end loop



Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
B-Man 31




PostPosted: Wed Nov 25, 2009 8:15 pm   Post subject: RE:Bullet in turing game is being weird. No idea how to fix, help needed badly.

ok, first of all, your wondering why it doesn't refresh after the the space bar is let go, this is because, in your program, the bullet only draws as long as the space bar is pressed. try moving the drawing f the bullet in the main loop. As for getting it to go in a straight line, you need to have another variable that isnt the x value of your ship.
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: