
-----------------------------------
snaz
Sun May 23, 2004 8:34 am

posted all me pic with game
-----------------------------------
Hi guys,  I am making the asteroid game and I am almost done. I need help to disappear the rock from screen when I shoot with my gun, and also how can I do this by chance if rock hit my plane, then the plan crash and after 2 second, new ship appear. Some one plz help cus this is my first and last assignment in Turing. i  post all the pics one more question where do i put background in my game. i am using keyboard not mouse. my friend told me that i have to use function or boolen and i don't know how, you can explain to me or can give me the codes. 

here are the codes of my game 




View.Set ("graphics:800;600,offscreenonly") 

var shipUpper : int := Pic.FileNew ("gun.jpg") 
var bulletUpper : int := Pic.FileNew ("bullet.jpg") 
var rock : int := Pic.FileNew ("rock.jpg") 
Pic.SetTransparentColour (rock, black) 
var shipDown : int := Pic.Rotate (shipUpper, 180, -1, -1) % Rotate for down arrow 
var shipLeft : int := Pic.Rotate (shipUpper, 90, -1, -1) % Rotate for left arrow 
var shipRight : int := Pic.Rotate (shipUpper, 270, -1, -1) % Rotate for right arrow 
var bulletDown : int := Pic.Rotate (bulletUpper, 180, -1, -1) 
var bulletLeft : int := Pic.Rotate (bulletUpper, 90, -1, -1) 
var bulletRight : int := Pic.Rotate (bulletUpper, 270, -1, -1) 

var x1, y1, x2, x3, y4, bulletX, bulletY, score, life, rockX, rockY : int := 0 
var keys : array char of boolean % they key currently being pressed 
var KEY_SPACEBAR : char := chr (32) 
var UP_ARROW : char := chr (200) 
var LEFT_ARROW : char := chr (203) 
var RIGHT_ARROW : char := chr (205) 
var DOWN_ARROW : char := chr (208) 

life := 20 
rockX := 20 
rockY := 700 

process rockDropping 
loop 
Pic.Draw (rock, rockX, rockY, picXor) 
View.Update 
Pic.Draw (rock, rockX, rockY, picXor) 
rockY := rockY - 10 
if rockY = 300 then 
cls 
Pic.Draw (shipDown, x2 + x3, y4 + y1, picMerge) 
y1 := y1 - 10 
elsif y4 + y1 = 500 then 
cls 
Pic.Draw (shipLeft, x2 + x3, y1 + y4, picMerge) 
x3 := x3 - 10 
end if 

locate (33, 87) 
color (white) 
put score, " : Score" 

locate (35, 87) 
color (white) 
put life, " : Life" 

View.Update 


end loop  [/img]

-----------------------------------
AsianSensation
Sun May 23, 2004 10:10 am


-----------------------------------
I believe there is a very detailed asteroid game source released when you install turing. You can always look through that. It covers everything, even Frames Per Second if you need it.

-----------------------------------
snaz
Mon May 24, 2004 1:07 pm

done everything just need help to disapear the rock
-----------------------------------
the game u get from turing it's pretty advance cus it's university level and i can't understand cus i am in grade 10. i done score and everything i just need to dispaer the rokc when  the bullet hit the rock 
here are the codes

View.Set ("graphics:800;600,offscreenonly")

colorback (black)

var shipUpper : int := Pic.FileNew ("gun3.jpg")
var bulletUpper : int := Pic.FileNew ("bullet.jpg")
var rock : int := Pic.FileNew ("rock.bmp")

var shipDown : int := Pic.Rotate (shipUpper, 180, -1, -1)      % Rotate for down arrow
var shipLeft : int := Pic.Rotate (shipUpper, 90, -1, -1)       % Rotate for left arrow
var shipRight : int := Pic.Rotate (shipUpper, 270, -1, -1)     % Rotate for right arrow
var bulletDown : int := Pic.Rotate (bulletUpper, 180, -1, -1)
var bulletLeft : int := Pic.Rotate (bulletUpper, 90, -1, -1)
var bulletRight : int := Pic.Rotate (bulletUpper, 270, -1, -1)

var x1, y1, x2, x3, y4, bulletX, bulletY, score, life, rockX, rockY : int := 0
var rockDead : boolean := true

var keys : array char of boolean % they key currently being pressed
var KEY_SPACEBAR : char := chr (32)
var UP_ARROW : char := chr (200)
var LEFT_ARROW : char := chr (203)
var RIGHT_ARROW : char := chr (205)
var DOWN_ARROW : char := chr (208)

life := 10
rockY := 700

process rockDropping
    loop
        if rockDead = true then
            Pic.Draw (rock, rockX, rockY, picXor)
            for b : 1 .. 20
                View.Update
            end for
            Pic.Draw (rock, rockX, rockY, picXor)
            if rockY < 0 then
                randint (rockX, 20, 500)
                randint (rockY, 700, 900)
                score := score - 5
                delay (500)
            end if
            rockY := rockY - 10
        elsif rockDead = false then
            Pic.Draw (rock, rockX, rockY, picXor)
            for b : 1 .. 20
                View.Update
            end for
            Pic.Draw (rock, rockX, rockY, picXor)
            if rockY < 0 then
                randint (rockX, 20, 500)
                randint (rockY, 700, 900)
                score := score - 5
                delay (500)
            end if
            rockY := rockY - 10
        end if
        exit when life = 0
    end loop
end rockDropping

fork rockDropping

loop

    colorback (black)

    Input.KeyDown (keys)

    if keys (UP_ARROW) then
        cls
        Pic.Draw (shipUpper, x2 + x3, y1 + y4, picMerge)
        if rockY = rockY - 10 then
                score := score + 10
                rockDead := false
            end if
            bulletY := bulletY + 10
        else
            bulletY := 0
        end if

    elsif keys (LEFT_ARROW) then
        cls
        Pic.Draw (shipLeft, x2 + x3, y1 + y4, picMerge)
        x2 := x2 - 10
        if keys (KEY_SPACEBAR) then
            Pic.Draw (bulletLeft, x2 + x3 - 40 - bulletX, y1 + y4 + 35, picMerge)
            if x2 + x3 - 40 - bulletX + 10 >= rockX and y1 + y4 + 35 >= rockY - 10 then
                score := score + 10
                rockDead := false
            end if
            bulletX := bulletX + 10
        else
            bulletX := 0
        end if

    elsif keys (DOWN_ARROW) then
        cls
        Pic.Draw (shipDown, x2 + x3, y4 + y1, picMerge)
        y4 := y4 - 10
        if keys (KEY_SPACEBAR) then
            Pic.Draw (bulletDown, x2 + x3 + 34, y1 + y4 - 40 + bulletY, picMerge)
            if x2 + x3 + 34 >= rockX and y1 + y4 - 40 + bulletY - 10 >= rockY - 10 then
                score := score + 10
                rockDead := false
            end if
            bulletY := bulletY - 10
        else
            bulletY := 0
        end if

    elsif keys (RIGHT_ARROW) then
        cls
        Pic.Draw (shipRight, x3 + x2, y1 + y4, picMerge)
        x3 := x3 + 10
        if keys (KEY_SPACEBAR) then
            Pic.Draw (bulletRight, x2 + x3 + 131 + bulletX, y1 + y4 + 35, picMerge)
            if x2 + x3 + 131 + bulletX + 10 >= rockX and y1 + y4 + 35 >= rockY - 10 then
                score := score + 10
                rockDead := false
            end if
            bulletX := bulletX + 10
        else
            bulletX := 0
        end if
    end if

    if y1 + y4 >= 500 then
        cls
        Pic.Draw (shipDown, x2 + x3, y4 + y1, picMerge)
        y1 := y1 - 10
    elsif y4 + y1 = 450 then
        cls
        Pic.Draw (shipLeft, x2 + x3, y1 + y4, picMerge)
        x3 := x3 - 10
    end if

    if rockX = rockX and y1 + y4 + 35 >= rockY - 10 then 
                score := score + 10 
                rockDead := false 
            end if 
            bulletX := bulletX + 10 
        else 
            bulletX := 0 
        end if 

    elsif keys (DOWN_ARROW) then 
        cls 
        Pic.Draw (shipDown, x2 + x3, y4 + y1, picMerge) 
        y4 := y4 - 10 
        if keys (KEY_SPACEBAR) then 
            Pic.Draw (bulletDown, x2 + x3 + 34, y1 + y4 - 40 + bulletY, picMerge) 
            if x2 + x3 + 34 >= rockX and y1 + y4 - 40 + bulletY - 10 >= rockY - 10 then 
                score := score + 10 
                rockDead := false 
            end if 
            bulletY := bulletY - 10 
        else 
            bulletY := 0 
        end if 

    elsif keys (RIGHT_ARROW) then 
        cls 
        Pic.Draw (shipRight, x3 + x2, y1 + y4, picMerge) 
        x3 := x3 + 10 
        if keys (KEY_SPACEBAR) then 
            Pic.Draw (bulletRight, x2 + x3 + 131 + bulletX, y1 + y4 + 35, picMerge) 
            if x2 + x3 + 131 + bulletX + 10 >= rockX and y1 + y4 + 35 >= rockY - 10 then 
                score := score + 10 
                rockDead := false 
            end if 
            bulletX := bulletX + 10 
        else 
            bulletX := 0 
        end if 
    end if 

    if y1 + y4 >= 500 then 
        cls 
        Pic.Draw (shipDown, x2 + x3, y4 + y1, picMerge) 
        y1 := y1 - 10 
    elsif y4 + y1 = 450 then 
        cls 
        Pic.Draw (shipLeft, x2 + x3, y1 + y4, picMerge) 
        x3 := x3 - 10 
    end if 

    if rockX 