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

Username:   Password: 
 RegisterRegister   
 some one please help me in my game
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
snaz




PostPosted: Sat May 22, 2004 8:39 pm   Post subject: some one please help me in my game

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. i cna't post the pics cus i don't know how and one more question where do i put background in my game. i am using keyboard not mouse

here are the codes of my game



code:
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
Sponsor
Sponsor
Sponsor
sponsor
Delta




PostPosted: Sat May 22, 2004 9:21 pm   Post subject: (No subject)

I hope I don't sound rude by saying this. But you people piss me off, of course by you people I mean the type of person who expects help on their project when they haven't even posted the pictures! Hint : Learn how to post all required pieces of your project.

But anywho.

Just simply stop drawing the rock, stop moving the rock, and stop checking for collision with the rock. Simple.

use something like this.

code:
If rock = "dead" then
else
%Move
%Draw
%Collision
end if
Paul




PostPosted: Sat May 22, 2004 9:25 pm   Post subject: (No subject)

lol Delta, these ppl don't piss me off, they crack me up.
http://www.compsci.ca/v2/viewtopic.php?t=5049
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  [ 3 Posts ]
Jump to:   


Style:  
Search: