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

Username:   Password: 
 RegisterRegister   
 Shooting
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Guy




PostPosted: Mon May 16, 2005 11:27 am   Post subject: Shooting


I need to find out how to shoot with a character (red) in my game......


var x, x2, y, y2 : int := 200
loop
colorback (black)
cls
setscreen ("graphics: vga")
drawfillbox (50, 110, 40, 280, white)
drawfillbox (590, 110, 600, 280, white)
drawfillbox (490, 0, 500, 25, white)
drawfillbox (490, 375, 500, maxy, white)
drawfillbox (125, 375, 135, maxy, white)
drawfillbox (125, 0, 135, 25, white)
drawfilloval (320, 190, 50, 50, white)
drawfilloval (450, 200, 5, 5, blue)
drawfilloval (x, y, 5, 5, red)
var input : char := getchar
if input = KEY_UP_ARROW then
y := y + 5
elsif input = KEY_DOWN_ARROW then
y := y - 5
elsif input = KEY_LEFT_ARROW then
x := x - 5
elsif input = KEY_RIGHT_ARROW then
x := x + 5
end if

end loop
Sponsor
Sponsor
Sponsor
sponsor
jamonathin




PostPosted: Mon May 16, 2005 1:29 pm   Post subject: (No subject)

elaborate more on what you want to shoot / where you want to shoot / how many times. For all I know you want him to shoot turds at the white bars.

I cleaned your program up a touch, it was aggrivating me.

Turing:

var x, x2, y, y2 : int := 200
var input : array char of boolean
setscreen ("offscreenonly")
loop
    colorback (black)
    cls
    drawfillbox (50, 110, 40, 280, white)
    drawfillbox (590, 110, 600, 280, white)
    drawfillbox (490, 0, 500, 25, white)
    drawfillbox (490, 375, 500, maxy, white)
    drawfillbox (125, 375, 135, maxy, white)
    drawfillbox (125, 0, 135, 25, white)
    drawfilloval (320, 190, 50, 50, white)
    drawfilloval (450, 200, 5, 5, blue)
    drawfilloval (x, y, 5, 5, red)
    View.Update
    Input.KeyDown (input)
    if input (KEY_UP_ARROW) then
        y := y + 5
    elsif input (KEY_DOWN_ARROW) then
        y := y - 5
    elsif input (KEY_LEFT_ARROW) then
        x := x - 5
    elsif input (KEY_RIGHT_ARROW) then
        x := x + 5
    end if
    delay (10)
end loop


Also check tutorials for shooting, or use the search engine at the top.
MysticVegeta




PostPosted: Mon May 16, 2005 3:37 pm   Post subject: (No subject)

code:
var x, x2, y, y2 : int := 200
var input : array char of boolean
setscreen ("offscreenonly")
loop
    colorback (black)
    cls
    % drawfillbox (50, 110, 40, 280, white)
    % drawfillbox (590, 110, 600, 280, white)
    % drawfillbox (490, 0, 500, 25, white)
    % drawfillbox (490, 375, 500, maxy, white)
    % drawfillbox (125, 375, 135, maxy, white)
    % drawfillbox (125, 0, 135, 25, white)
    % drawfilloval (320, 190, 50, 50, white)
    drawfilloval (450, 200, 5, 5, brightblue)
    drawfilloval (x, y, 5, 5, brightred)
    View.Update
    Input.KeyDown (input)
    if input (KEY_UP_ARROW) then
        y := y + 5
    elsif input (KEY_DOWN_ARROW) then
        y := y - 5
    elsif input (KEY_LEFT_ARROW) then
        x := x - 5
    elsif input (KEY_RIGHT_ARROW) then
        x := x + 5
    elsif input (KEY_ESC) then
        % colour (0)
        % locate(1, 1)
        % put x
        for s : x .. maxx
            if s > x + 20 then
                drawline (s - 11, y, s + 1, y, black)
                drawline (s - 10, y, s, y, white)
                View.Update
                delay (1)
            end if
        end for
    end if
    delay (10)
end loop

You mean something like that? If you want to make it something like after you shoot, immediately you can move without waiting for the bullet to get at the end then i would suggest you learn "procedures" and "forward"ing them
jamonathin




PostPosted: Tue May 17, 2005 5:49 am   Post subject: (No subject)

Thats actually a bad method for shooting. Just check for where the bullet is constantly, and if the bullet is less than your target, then have it keep moving, like this.
code:
var x, x2, y, y2 : int := 200
var shot : boolean := false
var bulletx, bullety : int := 0
var input : array char of boolean
setscreen ("offscreenonly")
loop
    colorback (black)
    cls
    % drawfillbox (50, 110, 40, 280, white)
    % drawfillbox (590, 110, 600, 280, white)
    % drawfillbox (490, 0, 500, 25, white)
    % drawfillbox (490, 375, 500, maxy, white)
    % drawfillbox (125, 375, 135, maxy, white)
    % drawfillbox (125, 0, 135, 25, white)
    % drawfilloval (320, 190, 50, 50, white)
    drawfilloval (450, 200, 5, 5, brightblue)
    drawfilloval (x, y, 5, 5, brightred)
    Input.KeyDown (input)
    if input (KEY_UP_ARROW) then
        y := y + 5
    elsif input (KEY_DOWN_ARROW) then
        y := y - 5
    elsif input (KEY_LEFT_ARROW) then
        x := x - 5
    elsif input (KEY_RIGHT_ARROW) then
        x := x + 5
    elsif input (KEY_ESC) and shot = false then
        shot := true
        bulletx := x + 5
        bullety := y
    end if
    if bulletx < maxx and shot then
        bulletx += 5
        drawline (bulletx, bullety, bulletx + 10, bullety, white)
    elsif bulletx >= maxx then
        shot := false
    end if
    View.Update
    delay (10)
end loop
Guy




PostPosted: Wed May 18, 2005 11:20 am   Post subject: THANKS

Thanks for da help
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  [ 5 Posts ]
Jump to:   


Style:  
Search: