Computer Science Canada

need help in disapearing the rock from screen

Author:  snaz [ Tue May 18, 2004 8:35 pm ]
Post subject:  need help in disapearing the rock from screen

Hi guys, this is my first time that I am posting here. 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 after2 second, new ship appear. Some one plz help cus this is my first and last assignment in Turing.

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 <= 0 then
randint (rockX, 20, 500)
randint (rockY, 700, 900)
rockY := rockY - 10
end if
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)
y1 := y1 + 10
if keys (KEY_SPACEBAR) then
Pic.Draw (bulletUpper, x2 + x3 + 34, y1 + y4 + 120 + bulletY, picMerge)
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, y1 + y4 + 35 - bulletX, picMerge)
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)
bulletY := bulletY - 7
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, y1 + y4 + 35 + bulletX, picMerge)
bulletX := bulletX + 10
else
bulletX := 0
end if
end if

if y1 + y4 >= 300 then
cls
Pic.Draw (shipDown, x2 + x3, y4 + y1, picMerge)
y1 := y1 - 10
elsif y4 + y1 <= 0 then
cls
Pic.Draw (shipUpper, x2 + x3, y1 + y4, picMerge)
y4 := y4 + 10
elsif x2 + x3 < 0 then
cls
Pic.Draw (shipRight, x3 + x2, y1 + y4, picMerge)
x2 := x2 + 10
elsif x3 + x2 >= 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

Author:  Delos [ Tue May 18, 2004 8:53 pm ]
Post subject: 

Ok...

1) Use [code] tags.
2) Nice code...but we don't have the pics you speak of in it. Zip everything together then post that.
3) Don't post all your code, just your problem areas.
4) Don't use processes for a programme this simple.
5) Please don't use processes.
6) Many people here have computers several hundred times faster and better than those that you use at your school/home...thus being you will most likely need Time.Delay()s in your prog...

Fix and then repost...you'll get better answers quicker.

Author:  snaz [ Tue May 18, 2004 10:09 pm ]
Post subject:  attach all the pics with codes

i attach all the pics and i already posted the game codes, one more question where can i put my background in my program thanks for helping

Author:  snaz [ Wed May 19, 2004 9:27 pm ]
Post subject:  y is no one giving the response

hi guys i posted my problem why is some one is not helping me, plz someone help me, i am not posting my problen cus i alreadt posted adn also i posted all the pic

Author:  LiquidDragon [ Thu May 20, 2004 2:39 pm ]
Post subject: 

your still missing pictures

Author:  snaz [ Thu May 20, 2004 5:23 pm ]
Post subject:  posted my pics

hi, i posted my pic, plz some one hlp me

Author:  snaz [ Thu May 20, 2004 5:37 pm ]
Post subject:  POsted correct pics

hi, sorry my bad i didn't attach the pics , but this time i did. i ma not posting my problem again cus i already posted in,. plz help me

Author:  snaz [ Thu May 20, 2004 5:48 pm ]
Post subject: 

hi, this time i posted all my pic of my game and i already posted the codes and my problem, plz help me

Author:  snaz [ Thu May 20, 2004 5:51 pm ]
Post subject: 

hi, this time i posted all my pic of my game and i already posted the codes and my problem, plz help me

Author:  snaz [ Thu May 20, 2004 5:55 pm ]
Post subject: 

sorry, i tried 3 times but i cna't post the pics i don't know y. just write down the codes adn i already posted the codes and my problem, plz help me

Author:  snaz [ Thu May 20, 2004 5:56 pm ]
Post subject: 

if u cna't help me with out the pics then click http://www.compsci.ca/v2/viewtopic.php?p=48523#48523
you will get pics

Author:  snaz [ Fri May 21, 2004 3:55 pm ]
Post subject:  PLease some one help me

i posted my prrblem two days ago but no one is helping me, pls some one hlep adn i am not posting my problem cus i already posted it


: