
-----------------------------------
vapour99
Sun Jun 01, 2008 6:44 pm

How to take a &quot;snapshot&quot; of the XY coordinates to fire a bullet from an oval
-----------------------------------
I am currently coding a SHUMP (spaceship shooter) game for my Grade 10 coding class and have encountered a simple problem:
When I move the ship, the bullets shot from the ship move as well.
The game is in its very early stages with simple titles and animations, but I need to solve this problem before I can continue programming the logic part of the game.

here is the code:

 var win, win2 : int
var message : string
var keyup : real
var count : real
var chars : array char of boolean
var x1, x2, y1, y2, xb1, yb1 : int
var x3, x4, y3, y4 : int
var clr : int
var shot : int
var mx, my, button : int
var boomy1, boomx1, boomy2, boomx2 : int
var continue : string

win := Window.Open ("position:middle,center, graphics: 640;800, Title: pauls moveoval")

View.Set ("offscreenonly")

x1 := 320
y1 := 20
x2 := 20
y2 := 20
clr := 2
boomx1 := 1
boomy1 := 1

process oval1
    Draw.FillOval (x1, y1, x2, y2, 1)
end oval1

process bullet %need to take a snapshot of the x/y cordinates of the mouse and fire a bullet straight up without (so mouse wont move bullet) ALSO NEEDS TO STOP FLASHING (viewupdate)
    xb1 := mx
    yb1 := my
    shot := 1
    for a : 1 .. 1000

        drawfilloval (xb1, yb1 + a, 10, 10, brightred)
        delay (1)
        drawfilloval (yb1, yb1 + a, 10, 10, 0)

    end for

end bullet

put "Welcome to Paul's Space shooter"
put " "
put " Mouse Rclick = shoot"
put " Mouse = movment"
put " "
put "type y to play, n to quit"
View.Update
get continue

if continue = "n"
        then
    Window.Close (win)
end if


loop
    shot := 0
    if continue = "n"
            then
        exit
    end if

    mousewhere (mx, my, button)
    Draw.FillOval (mx, my, x2, y2, 1)

    if button = 1 then
        fork bullet
    end if
    if y1 >= 800
            then
        y1 := 800
    end if

    if x1 >= 640
            then
        x1 := 640
    end if

    if x1 