While I have got my engine working better now. I need to work on some codes for damage. No I don't want things to be loaded externally, I need help with putting it in the engine. I put in a code like this on EnemyS
if (collision(TYPE playerbullet)) HP = Hp - 1; end
if (HP < 0) break; end
and in the Private part of that code I put
HP = 3;
in Begin, I put code so the health of it will display on screen (so I can debug/test the code to see if it actually works) but this is the problem. The number doesnt go down, and I have to pump the enemy full of bullets before it disappears as in this video: DELETED. Could it be that because in playerbullet I have this:
if (collision(TYPE EnemyS))
// do whatever you are supposed to do when you hit an enemy
break;
end
That its conflicting with the enemy? Please help with actual results, my deadline grows bigger each day.
Also, do you know of a code that would transform one object into another object? And then do you know a code that reloads the level, background music and all? Thanks
maybe you're using write() instead of write_var(), so it doesn't refresh.
Or maybe (i don't know if this would be right) the bullet is dying before the player or the enemy could detect its collision...
Ok that solves 1 half of the problem. Im guessing because the bullet code is actually before the enemy code its deleting first?
Probably yes. You can use the local priority (http://wiki.bennugd.org/index.php?title=Priority) variable to change the order in which instances are executed. It might however be prettier to handle the collision in one spot instead of two. The reason the collision() process works in if statements is that it returns the ID of the process it's colliding with and that IDs are always odd numbers(which evaluate to true).
Example:
if(procID = collision(type playerBullet))
signal(procID, S_KILL);
hp--; //Equals hp = hp - 1;
end
This would remotely kill the bullet. If you would want the bullet to do something(explode, fall down) afterwards you could put that code in the OnExit (http://wiki.bennugd.org/index.php?title=Onexit) part of the process.
Also, if at some point you'd have a lot of things that can hit and damage an enemy, you might want to make hp a public (http://wiki.bennugd.org/index.php?title=Public) variable so all those bullets/things can check for collisions and do damage to the player without cluttering the player process.
I put in this code
Process Entity_SmallExplosion(x,y)
Private
int i;
Begin
ctype=c_scroll;
SmallExplosion_graph[0]=load_png(".\sprites\entities\smallexplosion\se1.png");
SmallExplosion_graph[1]=load_png(".\sprites\entities\smallexplosion\se2.png");
SmallExplosion_graph[2]=SmallExplosion_graph[0];
SmallExplosion_graph[3]=SmallExplosion_graph[3];
loop
if(!SmallExplosion_graph[3])
graph=SmallExplosion_graph[i];
i=i+1;
else break; end
frame;
end
end
at the very end my my code and i am now getting a severe glitch. this only appears once the enemy is killed (its an explosion lol). but once the animation ends, it ends the game. I though that by add the if part to my code that would help things but it didnt. any ideas? is it just some random bug? thanks.
Are you sure about this code (the first line)
if (!SmallExplosion_graph[3])
graph=SmallExplosion_graph[i];
i=i+1;
else
break;
end
if (!SmallExplosion_graph[3]) always returns false, because it is not checked against
another condition. You could read this as
if (false)
Unless it is consiously intentional, it is generally not a good idea.
Better is to do
if (graph <> SmallExplosion_graph[3])
graph=SmallExplosion_graph[i];
i=i+1;
else
break;
end
That didnt do anything :/ or not that I can notice, it doesnt display the animation at all. I tried moving the part in the enemies code where it would appear in the OnExit and I changed the small explosion back but that didnt change anything. Like I said I put the if thing in th code to see if that would do anything and it doesnt do anything. I thought yours would work, but Im confused now. Is this just some weird bug?
It may be a logic error in your program. That's often a cause for bugs.
This is why the design is so important. If you put some say() statements in the
code at points that are suspicious, you can monitor the logic flow in your program.
Ill modify my "send-out" code (the one i sent you earlier) so it has the bullet stuff in it, ill email it to you so you can see why its crashing, i put say commands in my game though. I dont exactly know where to monitor them in notepad++.
EDIT:
Wait... I fixed it lol I changed the if to this
if (graph! = SmallExplosion_graph[3])
now that was weird, doesnt the code mean the exact same thing as the one you showed me?
Here's the problems that I am having so far:
*I have to get hit once to activate getting hurt, even when I die and come back I have to get hit for it to activate.
*I have no idea how to reload the level
*I have no idea how to change the level
*I am confused on how to incorporate a menu