
-----------------------------------
Thuged_Out_G
Sat Dec 13, 2003 1:05 am

Shooter game
-----------------------------------
this program is really flickery, and the Pic.Draw doesnt seem to stay on the screen :S...as soon as i let go of the mouse, it goes away...any help please


var x, y, button, picID : int
picID := Pic.FileNew ("bullet1.bmp")
drawfill (1, 1, black, black)

proc Shoot
    cls
    Draw.FillArc (x, y, 100, 100, 100, 100, 10)
    drawfillarc (x, y, 100, 100, 100, 100, 10)
    Draw.Oval (x, y, 100, 100, 10)
    Draw.Oval (x, y, 80, 70, 10)
    Draw.Oval (x, y, 60, 50, 10)
    Draw.Oval (x, y, 40, 30, 10)
    Draw.Oval (x, y, 20, 10, 10)
    Draw.Oval (x, y, 100, 0, 10)
    Draw.Oval (x, y, 0, 100, 10)
end Shoot


loop
    Mouse.Where (x, y, button)
    if button = 0 then
        Shoot
    elsif button = 1 then
        Pic.Draw (picID, x, y, picMerge)
        View.Update
    end if
end loop


-----------------------------------
drumersrule123
Sat Dec 13, 2003 1:28 am


-----------------------------------
i put a delay in front of the cls it slowed it down a bit but it didn't flicker that much here is the code

proc Shoot
    delay (150)
    cls

-----------------------------------
drumersrule123
Sat Dec 13, 2003 1:30 am


-----------------------------------
you probbly don't want to use a delay over 250

-----------------------------------
Homer_simpson
Sat Dec 13, 2003 12:02 pm


-----------------------------------
u forgot setscreen("offscreenonly")...
setscreen ("offscreenonly")
var x, y, button, picID : int
picID := Pic.FileNew ("bullet1.bmp")
drawfill (1, 1, black, black)

proc Shoot
    cls
    Draw.FillArc (x, y, 100, 100, 100, 100, 10)
    drawfillarc (x, y, 100, 100, 100, 100, 10)
    Draw.Oval (x, y, 100, 100, 10)
    Draw.Oval (x, y, 80, 70, 10)
    Draw.Oval (x, y, 60, 50, 10)
    Draw.Oval (x, y, 40, 30, 10)
    Draw.Oval (x, y, 20, 10, 10)
    Draw.Oval (x, y, 100, 0, 10)
    Draw.Oval (x, y, 0, 100, 10)
end Shoot


loop
    Mouse.Where (x, y, button)
    if button = 0 then
        Shoot
    elsif button = 1 then
        Pic.Draw (picID, x, y, picMerge)
    end if
    View.Update
end loop


-----------------------------------
DanShadow
Sat Dec 13, 2003 5:05 pm


-----------------------------------
Yeah, when drawing the target over the mouse, "cls", then at the top of the loop, put:
setscreen("offscreenonly")
View.Update
This stops the flickering, thats how I fixed my shooter.  :)

-----------------------------------
Thuged_Out_G
Sat Dec 13, 2003 6:16 pm


-----------------------------------
ok, all is good now...except when i draw the pic it doesnt stay on screen :S

-----------------------------------
DanShadow
Sat Dec 13, 2003 6:33 pm


-----------------------------------
Make an array the holds the (x,y) co-ordinates of all shots taken. But make sure that the game doesnt drag on too long, or the array will overflow, heh.

-----------------------------------
Thuged_Out_G
Sat Dec 13, 2003 7:14 pm


-----------------------------------
im not quite understanding what you mean, the cls in the shoot procedure just keeps getting rid of the pic


var x, y, button, picID : int
picID := Pic.FileNew ("bullet1.bmp")
drawfill (1, 1, black, black)
var shoots : array 1 .. 1000 of int

proc Shoot
    cls
    Draw.FillArc (x, y, 100, 100, 100, 100, 10)
    drawfillarc (x, y, 100, 100, 100, 100, 10)
    Draw.Oval (x, y, 100, 100, 10)
    Draw.Oval (x, y, 80, 70, 10)
    Draw.Oval (x, y, 60, 50, 10)
    Draw.Oval (x, y, 40, 30, 10)
    Draw.Oval (x, y, 20, 10, 10)
    Draw.Oval (x, y, 100, 0, 10)
    Draw.Oval (x, y, 0, 100, 10)
end Shoot

loop
for i : 1 .. 5
    setscreen ("offscreenonly")
    View.Update
    Mouse.Where (x, y, button)
    if button = 0 then
        Shoot
    elsif button = 1 then
        shoots (i) := x
        shoots (i + 1) := y
        Pic.Draw (picID, x-30, y-30, picMerge)
    end if
end for
end loop


is that what you are talking about

-----------------------------------
DanShadow
Sat Dec 13, 2003 8:27 pm


-----------------------------------

%The Bullets Shot Array
var bullet_x, bullet_y : array 1 .. 200 of int
var num : int := 0
%Makes everything in array equal to 999
for i : 1 .. 200
    bullet_x (i) := 700
    bullet_y (i) := 700
end for

var x, y, button, picID : int
picID := Pic.FileNew ("Bullet.bmp")
drawfill (1, 1, black, black)
var shoots : array 1 .. 1000 of int

proc Shoot
    cls
    Draw.FillArc (x, y, 100, 100, 100, 100, 10)
    drawfillarc (x, y, 100, 100, 100, 100, 10)
    Draw.Oval (x, y, 100, 100, 10)
    Draw.Oval (x, y, 80, 70, 10)
    Draw.Oval (x, y, 60, 50, 10)
    Draw.Oval (x, y, 40, 30, 10)
    Draw.Oval (x, y, 20, 10, 10)
    Draw.Oval (x, y, 100, 0, 10)
    Draw.Oval (x, y, 0, 100, 10)
end Shoot

%Procedure to draw past done bullets
procedure drawBullets
    for i : 1 .. 200
        Draw.FillOval (bullet_x (i), bullet_y (i), 5, 5, 255)
    end for
end drawBullets

loop
    num := 0
    for i : 1 .. 5
        setscreen ("offscreenonly")
        View.Update
        Mouse.Where (x, y, button)
        if button = 0 then
            Shoot

            %Draw Previous Bullets
            drawBullets

        elsif button = 1 then
            shoots (i) := x
            shoots (i + 1) := y
            Pic.Draw (picID, x - 30, y - 30, picMerge)

            %When you shoot, this checks array for first open slot
            %Then it records the x and y where you just shot
            %This way, it can redraw that shot place over and over
            loop
                num := num + 1
                exit when bullet_x (num) = 700
            end loop
            bullet_x (num) := x
            bullet_y (num) := y

        end if
    end for
end loop

There ya go. I added onto the code, so everytime it finishes the loop, it redraws a black oval (10*10) where ever you have shot before
enjoy

-----------------------------------
Homer_simpson
Sun Dec 14, 2003 12:37 am


-----------------------------------
bullshit!!!!
very slow... just draw the picture everytime after cls...

edit...
NVM... i just read what you said  :oops: 
