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

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




PostPosted: Tue Mar 01, 2005 11:55 am   Post subject: Need Help with Shooter

Now i know this looks really cheesy and ugly, but I just edited out the pictures, because right now they're not necessary (just picture a guy holding a m4a1 from cs, in whatever level you pick, only moving side to side). ANYWAYS . . . what i need help with is, i'm prolly doing sumthin really dumb but i cant get the bullets to stay where i shoot them, i shoot, and they move with me, PleH!
code:

setscreen ("graphics:200;100,nobuttonbar,position:center;center,title:Pick Level")
colorback (black)
cls
color (yellow)
put " Choose a Level [1-4]."
color (white)
put " 1 - Inferno"
put " 2 - Militia"
put " 3 - Assault"
put " 4 - Italy"
var mc : int
locate (6, 13)
color (yellow)
get mc
setscreen ("graphics:500;300,nobuttonbar,position:center;center,offscreenonly,title:TMaCz Productions Presents. . .")
colorback (white)
var mapsize : int := 600
var mx, my, mz : int := 50
var ammo : int := 99
var reloads : int := 999
var dif : int := 5
var crosshair : int := 12
var bsavex, bsavey : array 1 .. 99 of int
var bulletx, bullety, shake : int := 0
var font : int := Font.New ("BankGothic Md BT:14:bold")
var mapx, mapx2, mapy, mapy2, gun, guny, gunx : int := 0
guny := -20
gunx := 180
mapx2 := mapsize
mapy := -25
mapy2 := -25
gun := 1
var shot : int := 0
var spark : array 1 .. 3 of int
var guns : array 1 .. 4 of int
var key : array char of boolean
var shoot : int := 0
forward proc fire

proc refresh
    cls
    drawfillbox (mapx, mapy, mapx + mapsize, maxy, 10)
    drawfillbox (mapx2, mapy2, mapx2 + mapsize, maxy, brightblue)
    drawline (maxx div 2 - 23 - shake, my, maxx div 2 - 27 - shake, my, crosshair)
    drawline (maxx div 2 - 17 + shake, my, maxx div 2 - 13 + shake, my, crosshair)
    drawline (maxx div 2 - 20, my + shake + 3, maxx div 2 - 20, my + 7 + shake, crosshair)
    drawline (maxx div 2 - 20, my - shake - 3, maxx div 2 - 20, my - 7 - shake, crosshair)
    guny := my div 5 - 60
    if my > maxy then
        guny := 0
    elsif my < 0 then
        guny := -60
    end if
    if shot > 0 then
        % Pic.Draw (spark (shot), gunx + 40, 80 + guny, picMerge)
    end if
    %if mz = 1 and ammo > 0 then
    %    drawfilloval (bulletx, bullety, 1, 1, black)
    %end if
    if 99 - ammo > 0 then
        for i : 1 .. 99 - ammo
            drawfilloval (bsavex (i), bsavey (i), 1, 1, black)
        end for
    end if
    drawfillbox (gunx, guny + 10, gunx + 15, guny + 40, black)
    Font.Draw (intstr (ammo), 400, 5, font, 67)
    Font.Draw ("|", 435, 5, font, 67)
    Font.Draw (intstr (reloads), 445, 5, font, 67)
    View.Update
    delay (0)
end refresh

body proc fire
    gunx += 2
    guny -= 1
    shot := 1
    refresh
    gunx -= 3
    guny += 2
    shot := 3
    refresh
    gunx += 1
    guny -= 1
    shot := 2
    refresh
end fire

loop
    Input.KeyDown (key)
    mousewhere (mx, my, mz)
    if mz = 1 and ammo > 0 then
        dif := 5
        ammo -= 1
        randint (bulletx, maxx div 2 - 20 - shake, maxx div 2 - 20 + shake)
        randint (bullety, my - shake, my + shake)
        if 99 - ammo > 0 then
            bsavex (99 - ammo) := bulletx
            bsavey (99 - ammo) := bullety
        end if
        shake += 1
        fire
    else
        shake := 0
        dif := 5
        shot := 0
        refresh
    end if
    if key ('a') then
        mapx += dif
        mapx2 += dif
        if 99 - ammo > 0 then
            for i : 1 .. 99 - ammo
                bsavex (99 - ammo) += dif
            end for
        end if
        if mapx >= maxx then
            mapx := mapx2 - mapsize
        elsif mapx2 >= maxx then
            mapx2 := mapx - mapsize
        end if
    elsif key ('d') then
        mapx -= dif
        mapx2 -= dif
        if 99 - ammo > 0 then
            for i : 1 .. 99 - ammo
                bsavex (99 - ammo) -= dif
            end for
        end if
        if mapx + mapsize <= maxx - mapsize then
            mapx := maxx - dif
        elsif mapx2 + mapsize <= maxx - mapsize then
            mapx2 := maxx - dif
        end if
    end if
    if key (KEY_CTRL) or key (KEY_SHIFT) then
        mapy := 0
        mapy2 := 0
    elsif key (' ') then
        mapy := -50
        mapy2 := -50
    else
        mapy := -25
        mapy2 := -25
    end if
    if key ('r') and reloads - 99 > 0 then
        reloads -= 99 - ammo
        ammo := 99
        refresh
        delay (100)
    elsif key ('r') and reloads - 99 < 0 and reloads > 0 then
        ammo := reloads
        reloads := 0
    end if
end loop
/* r = reload, wasd to move, space = stand high, ctrl or shift to crouch, and mouse
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Tue Mar 01, 2005 12:01 pm   Post subject: (No subject)

Quote:

i'm prolly doing sumthin really dumb


Indeed you are! You've posted this in the wrong section. This is Turing Submissions, not Turing Help. Please kindly ask a mod to have this moved...
jamonathin




PostPosted: Tue Mar 01, 2005 12:06 pm   Post subject: (No subject)

. . . *sigh* . . . another blonde moment Hit Wall
Tony




PostPosted: Tue Mar 01, 2005 1:27 pm   Post subject: (No subject)

Quote:

bsavex (99 - ammo) := bulletx
bsavey (99 - ammo) := bullety

I'm guessing this is where you're saving the bullet marks.

That's a position where it was shot on the screen. You forgot to include any information about direction you were facing when the shot was made. If you're just spinning around in circles, a simple position offset would do.
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  [ 4 Posts ]
Jump to:   


Style:  
Search: