Help needed with variables and Procedures.
Author |
Message |
chimerix
|
Posted: Wed Nov 25, 2009 9:49 am Post subject: Help needed with variables and Procedures. |
|
|
What is it you are trying to achieve?
Im trying to make a game similar to space invaders except the collision isnt working. I think its because one procedure doesn't have the variable values needed to do the actual collision.
Describe what you have tried to solve this problem
I'v wrote most of the program (ITS REALLY BAD AND MESSY- beginner programmer)
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
View.Set ("graphics:300;450,nobuttonbar")
var background : int := Pic.FileNew ("background2.bmp")
Pic.Draw (background, 0, 0, picCopy)
var y, x, z, movement : int
var keys : array char of boolean
const LEFT_ARROW : char := chr (203)
const RIGHT_ARROW : char := chr (205)
const KEY_SPACE : char := chr (32)
var blank : int := Pic.FileNew ("blank.bmp")
var tankpic : int := Pic.FileNew ("tank1.bmp")
var tankpic2 : int := Pic.FileNew ("tank2.bmp")
var explosion : int := Pic.FileNew ("explosion.bmp")
process attacker
loop
randint (x, 1, 300)
var pictureNumber : int := Pic.FileNew ("tank2.bmp")
for y : 1 .. 500
Pic.Draw (pictureNumber, x, (y * - 1) + 450, picCopy)
delay (5)
end for
end loop
end attacker
process collision
if movement >= x then
Pic.Draw (blank, x, y, picCopy)
delay (5)
Pic.Draw (explosion, x, y, picCopy)
end if
end collision
procedure defender
movement := 0
for y : 0 .. 10000000
Pic.Draw (tankpic, movement, 10, picCopy)
delay (50)
Input.KeyDown (keys )
if keys (LEFT_ARROW ) then
movement := movement - 10
Pic.Draw (blank, movement + 15, 10, picCopy)
if movement = - 10 then
movement := movement + 10
end if
end if
if keys (RIGHT_ARROW ) then
movement := movement + 10
Pic.Draw (blank, (movement - 15), 10, picCopy)
if movement = 290 then
movement := movement - 10
end if
end if
if keys (KEY_SPACE ) then
for z : 1 .. 500
drawfilloval (movement + 10, z, 3, 3, black)
Pic.Draw (tankpic, movement, 10, picCopy)
delay (1)
drawfilloval (movement + 10, z, 3, 3, 4)
end for
end if
end for
end defender
loop
fork attacker
fork collision
defender
end loop
|
Please specify what version of Turing you are using
4.1.1 |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
killjackin61
|
Posted: Wed Nov 25, 2009 9:51 am Post subject: RE:Help needed with variables and Procedures. |
|
|
so weak, so much for no help topics in this forum |
|
|
|
|
 |
Tony

|
|
|
|
 |
chimerix
|
Posted: Wed Nov 25, 2009 3:56 pm Post subject: RE:Help needed with variables and Procedures. |
|
|
Thanks |
|
|
|
|
 |
B-Man 31

|
Posted: Wed Nov 25, 2009 8:16 pm Post subject: RE:Help needed with variables and Procedures. |
|
|
Also, you should get rid of the processes. |
|
|
|
|
 |
|
|