Space invaders aid!
Author |
Message |
Jorue
|
Posted: Tue Dec 08, 2009 2:01 pm Post subject: Space invaders aid! |
|
|
What is it you are trying to achieve?
Space Invaders game for my comp sci class
What is the problem you are having?
Bullets pass completely through the first row, then hit the enemy in the second row, doing what is should before crashing.
Describe what you have tried to solve this problem
I have looked over my variables and code and I haven't the slightest idea what is wrong.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
procedure enemycheck (shootx, shooty : int, var ehit : int)
for count : 1 .. 10
if shoot1x <= enemies1 (count, 2) + 10 and shoot1x >= enemies1 (count, 2) - 10 and shoot1y <= enemies1 (count, 3) + 10 and shoot1y >= enemies1 (count, 3) - 10 and enemies1 (count, 4) = 1 then
Sprite.Hide (enemies1 (count, 1))
enemies1 (count, 4) := 0
ehit := 1
exit
end if
if shoot1x <= enemies2 (count, 2) + 10 and shoot1x >= enemies2 (count, 2) - 10 and shoot1y <= enemies2 (count, 3) + 10 and shoot1y >= enemies2 (count, 3) - 10 and enemies2 (count, 4) = 0 then
Sprite.Hide (enemies2 (count, 1))
enemies2 (count, 4) := 0
ehit := 1
exit
end if
if shoot1x <= enemies3 (count, 2) + 10 and shoot1x >= enemies3 (count, 2) - 10 and shoot1y <= enemies3 (count, 3) + 10 and shoot1y >= enemies3 (count, 3) - 10 and enemies3 (count, 4) = 0 then
Sprite.Hide (enemies3 (count, 2))
enemies3 (count, 4) := 0
ehit := 1
exit
end if
if shoot1x <= enemies4 (count, 2) + 10 and shoot1x >= enemies4 (count, 2) - 10 and shoot1y <= enemies4 (count, 3) + 10 and shoot1y >= enemies4 (count, 3) - 10 and enemies4 (count, 4) = 0 then
Sprite.Hide (enemies4 (count, 1))
enemies4 (count, 4) := 0
ehit := 1
exit
end if
if shoot1x <= enemies5 (count, 2) + 10 and shoot1x >= enemies5 (count, 2) - 10 and shoot1y <= enemies5 (count, 3) + 10 and shoot1y >= enemies5 (count, 3) - 10 and enemies5 (count, 4) = 0 then
Sprite.Hide (enemies5 (count, 1))
enemies5 (count, 4) := 0
ehit := 1
exit
end if
if shoot1x <= enemies6 (count, 2) + 10 and shoot1x >= enemies6 (count, 2) - 10 and shoot1y <= enemies6 (count, 3) + 10 and shoot1y >= enemies6 (count, 3) - 10 and enemies6 (count, 4) = 0 then
Sprite.Hide (enemies6 (count, 1))
enemies6 (count, 4) := 0
ehit := 1
exit
end if
end for
end enemycheck
% And an example of the shooting
process shoot1
shoot1x := x
shoot1y := y - 155
Sprite.Show (bullets (1))
loop
Sprite.SetPosition (bullets (1), shoot1x, shoot1y, true)
enemycheck (shoot1x, shoot1y, hit )
delay (10)
shoot1y + = 5
exit when shoot1y > maxy or hit = 0
end loop
Sprite.Hide (bullets (1))
shot1 := 0
end shoot1
|
Please specify what version of Turing you are using
2, I think. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
mirhagk
|
Posted: Tue Dec 08, 2009 2:39 pm Post subject: RE:Space invaders aid! |
|
|
Turing 2??? go to www.holtsoft.com and download 4.1 or something. I don't really want to help you if you're using something that outdated |
|
|
|
|
|
Jorue
|
Posted: Tue Dec 08, 2009 2:41 pm Post subject: RE:Space invaders aid! |
|
|
Oh nonono. That's what I have then, this is on the school comps, and it was recently updated. I just wasn't sure, lol |
|
|
|
|
|
mirhagk
|
Posted: Tue Dec 08, 2009 2:45 pm Post subject: RE:Space invaders aid! |
|
|
oh okay lol, I was about to cry for you. Lol okay well first off that first procedure that passes in the ehit variable should really be a function. Here's what it'd be kinda like
Turing: |
function enemycheck(shootx,shooty:int):boolean
for i:1..10
if hits_it then
result true
end if
end for
result false
end enemycheck
|
|
|
|
|
|
|
Jorue
|
Posted: Tue Dec 08, 2009 2:47 pm Post subject: RE:Space invaders aid! |
|
|
Could you show me how to edit that in? ;-; We aren't at that level. Lawl, I've never heard of a function. QQ |
|
|
|
|
|
mirhagk
|
Posted: Tue Dec 08, 2009 2:51 pm Post subject: RE:Space invaders aid! |
|
|
damn school. okay well a function is basically a procedure except it returns something.
you call a procedure by typing
Turing: |
procedure myproc
put "Hello World!"
end myproc
myproc
|
but you call a function by the following
Turing: |
var msg:string
function myfcn:string
result "Hello World!"
end myfcn
msg:=myfcn
put msg
|
|
|
|
|
|
|
Superskull85
|
Posted: Tue Dec 08, 2009 3:08 pm Post subject: RE:Space invaders aid! |
|
|
Or you could just call "myfcn" within the put statement, and not store the return value in a variable:
Turing: | function myfcn () : string
result "Hello World!"
end myfcn
put myfcn () |
|
|
|
|
|
|
mirhagk
|
Posted: Tue Dec 08, 2009 3:10 pm Post subject: RE:Space invaders aid! |
|
|
but considering the fact that he's never heard of functions before, I figured storing it in a variable would be easier for him to understand. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Insectoid
|
Posted: Tue Dec 08, 2009 6:17 pm Post subject: RE:Space invaders aid! |
|
|
Considering the fact that he's never heard of functions before, I figure it's high time he learned. |
|
|
|
|
|
|
|