Ohhh ok. Then I have no idea. :(Zitat:
Zitat von Jeremy1026
Printable View
Ohhh ok. Then I have no idea. :(Zitat:
Zitat von Jeremy1026
it is actually a good thing to have in your code as u edit, so u dont have to reboot your game to test the changes, just press start. gets rid of the time it takes to display the gameboot.Zitat:
Zitat von PSPduh
actually "break" doesnt exit the program. it only exits the loop. so if u had two loops, it would transfer the control to the other loop.
-= Double Post =-
okay, n00b question:
this is my code:
Code:-- loaded images
health1 = 100
health2 = 100
hit1 = "false"
hit2 = "false"
-- added the bullet stuff
function collision()
for g = 1, 10 do
if (BulletInfo[g].x < Player[2].x + 32) and (BulletInfo[g].x > Player[2].x) and (BulletInfo[g].y < Player[2].y + 32) and (BulletInfo[g].y + 5 > Player[2].y) then
BulletInfo[g].firing = false
hit2 = "true"
end
end
for h = 1, 10 do
if (BulletInfo2[h].x < Player[1].x + 32) and (BulletInfo2[h].x > Player[1].x) and (BulletInfo2[h].y < Player[1].y + 32) and (BulletInfo2[h].y > Player[1].y) then
BulletInfo2[h].firing = false
hit1 = "true"
end
end
end
function health()
if health1 < 0 then
health1 = 0
end
if health2 < 0 then
health2 = 0
end
if (hit1 == "true") then
health1 = health1 - 10
hit1 = "false"
end
if (hit2 == "true") then
health2 = health2 - 10
hit2 = "false"
end
if health1 == 0 then
screen:clear()
screen:blit(0, 0, win2)
fire = false
end
if health2 == 0 then
screen:clear()
screen:blit(0, 0, win1)
fire = false
end
end
while true do
collision()
health()
screen.waitVblankStart()
screen.flip()
end
the problem is, even if one bullet hit the enemy, his health goes all the way down to 0 insted of just lowering by 10.
help.
How about in your function collision, instead of "hit2 = "true"" or "hit1 = "true"", just put, health1 = health1 - 10
You can exit from LuaPlayer using os.exit()
I never saw the point of that function when you could just use os.exit()Zitat:
Zitat von LMelior
Darnet! I wished I known that earlier. Too late now, I've already coded the program. It would be too much work to put that in. Guess I'll have to settle with the home button.Zitat:
Zitat von TheEmulatorGuy
This gives me more incentive to kill the people who gave the wrong advice.Zitat:
Zitat von Access_Denied
Hey, i just said the break function didnt work.. im no uber leet progger so dont kill me, BTW, does that acctualy work?
I wasn't referring to you. Yes, it does work. I use it in ID3PSP.Zitat:
Zitat von Branin
then the same thing happens.Zitat:
Zitat von Access_Denied