Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)

 Techique 05-20-2010 07:32 PM

HAHA! i see now thanks alot

 Dameria 05-20-2010 07:34 PM

 Techique 05-21-2010 11:27 AM

Hey dameria, if you there i was wondering how i could approach ammunition for the guns? i was thinking the same variable as health. but is there an easier way?

 Dameria 05-21-2010 03:54 PM

Just use a number variable called "ammo" and set it to the amount you want for that gun. Then, in the method where you shoot, say "if(ammo > 0), do the shoot method and decrement "ammo" by 1. You can then have a reloading method where you do the animation of reloading the gun, and at the end of the animation you do "ammo = (amount of ammo you want in the gun)". Once you do that you will have a system where you only shoot if you have a set amount of ammo in the gun, and once you run out you have to reload.

You can even go a step more realistic (only if you want) and have a limited amount of ammo overall, which could be another number variable called "totalAmmo", and in the reloading method you do "if((amount of ammo you want in gun) > totalAmmo), ammo = (amount of ammo you want in gun) - totalAmmo, else ammo = (ammount of ammo you want in gun)". Tell me if this does not make sense to you and maybe I will make an example.

 Watsamax1 05-21-2010 09:13 PM

It makes no sense :(. Id like a ammo system probably infinite ammo but you still gotta reload. I dont get what to do. Like where to put what. Lie put ammo= total ammo if it goes in reload or shoot.

 Dameria 05-21-2010 09:14 PM

[QUOTE=Watsamax1;21588]It makes no sense :(. Id like a ammo system probably infinite ammo but you still gotta reload. I dont get what to do. Like where to put what. Lie put ammo= total ammo if it goes in reload or shoot.[/QUOTE]

Do you want me to make an example world?

 Watsamax1 05-21-2010 09:26 PM

OMG I LOVE YOU it work it really works!!!!!!!! WWWOOOO:D:D:rolleyes::rolleyes::rolleyes::eek::eek:!!! yeah! thank you. your getting on the credits. Im working no a dinosaur shoot em up. its kinda like Jurassic park/tomb raider 3/ my imagination. Question now is health. :D um like an attack. i plan on if near so many meters t-rex attack. Also cutscene i cannot figure em out.

 Dameria 05-21-2010 09:36 PM

[QUOTE=Watsamax1;21590]OMG I LOVE YOU it work it really works!!!!!!!! WWWOOOO:D:D:rolleyes::rolleyes::rolleyes::eek::eek:!!! yeah! thank you. your getting on the credits. Im working no a dinosaur shoot em up. its kinda like Jurassic park/tomb raider 3/ my imagination. Question now is health. :D um like an attack. i plan on if near so many meters t-rex attack. Also cutscene i cannot figure em out.[/QUOTE]

Congrats, and by the way this whole thread is basically about the health system, so you can just look at previous posts to see what I told the other guy to do.

Also, for cutscenes you will have to create boolean variables like "canPlay", and you have to put EVERY method that you can do while playing the game in an "if(canPlay)" if statement before running each method, and drag the code for the method inside the if else statement (remember, EVERY method that allows the player to do something in the game, this includes moving, reloading, shooting methods, etc). You will have to create one of these if/elses for every method that is active while the game is played, but not the cutscenes. Have a the world variable "canPlay" set to true as the initial value (unless you want a cutscene in the beginning, then set it to false and put the code "canPlay = true" at the end of the cutscene). Then at every cutscene method (you will have to create a method for each cutscene and put the animation within that method), you will have to set "canPlay" to false as the first line of code (this will prevent the character from being able to move, shoot, reload, etc) and set "canPlay" to true at the end of the cutscene. Once you do this you should be able to control the cutscene without any interruptions from the player until the cutscene is over.

Tell me if this helped or just made you really confused. If you need help on the cutscenes themselves, that will be harder because that involves creativity, and you have to do that yourself (unless of course you want someone to help you create the actual cutscene to make it more realistic, but then it will not be created by you).

 Watsamax1 05-21-2010 09:52 PM

I may get it. But i just noticed if i reload i get infinite ammo and i dont have t reload :confused:

 Dameria 05-21-2010 10:07 PM

[QUOTE=Watsamax1;21593]I may get it. But i just noticed if i reload i get infinite ammo and i dont have t reload :confused:[/QUOTE]

What should happen is that you can only shoot the amount of times that there are bullets in the gun, but once the bullets in the clip run out you can reload, putting more bullets in the clip. Are you saying that you never need to reload, and you just keep shooting without it ever stopping? If so then make sure that either the shooting event being called in the events bar, or the entire shooting method itself if within a large if/else statement with what I said in the post before.

If its still not working right, take a print screen and upload the image of the code to the forums (you can black out the animation if you don't want to to see that part) and I can see what you did. If you do this though, make sure everything is showing including the world variables, the method for shooting, and the events bar where you called in the shooting method.

Or you can just ask and I will make a quick example and upload it on this thread. I think that many people will like to see an example anyways because they might be interested in a reloading example for their own worlds.

All times are GMT -5. The time now is 02:35 PM.