My first Game with ChilI Framework
My first Game with ChilI Framework
https://github.com/Aizenvolt1/Project1/ ... rstChanges
This is the first game I make and if you can help with some things I would apreciate it. I have seen the first 13 tutorials. I want some help with the firing mechanism if you see the code you will understand the problem but if you dont I will explain it anyway. You see I can't find the right way to code the firing mechanism. The way i have coded it won't help if i want the player to fire more shots. I am sure there is a better way to do it but since I am new to these things I havent figured it out yet. The game I have made is very basic the concept is similar to galaga. As i see more tutorials and learn new things i will improve my code and add new things.Also if there is a site that has images and pixels for those images and how to draw them in the code(like poo from chilis videos) I would appreciate it if you posted a link. Thanks to anyone that is kind enough to help.Press arrow keys to move SPACEBAR to fire Enter to start game and R to play again.
This is the first game I make and if you can help with some things I would apreciate it. I have seen the first 13 tutorials. I want some help with the firing mechanism if you see the code you will understand the problem but if you dont I will explain it anyway. You see I can't find the right way to code the firing mechanism. The way i have coded it won't help if i want the player to fire more shots. I am sure there is a better way to do it but since I am new to these things I havent figured it out yet. The game I have made is very basic the concept is similar to galaga. As i see more tutorials and learn new things i will improve my code and add new things.Also if there is a site that has images and pixels for those images and how to draw them in the code(like poo from chilis videos) I would appreciate it if you posted a link. Thanks to anyone that is kind enough to help.Press arrow keys to move SPACEBAR to fire Enter to start game and R to play again.
Last edited by Aizenvolt on August 14th, 2017, 6:18 pm, edited 1 time in total.
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: My first Game with ChilI Framework
How many shots are you wanting at a time?
Here's an idea, make an array of Fire large enough to hold however many shots you want to allow the player to make. Right now you only have two, you could make it 20 then make it so there is a counter on how many are active. Each time the player fires, you initialize a new Fire object and increase the active counter up until the active counter is at max or max - 1 anyway.
Here's an idea, make an array of Fire large enough to hold however many shots you want to allow the player to make. Right now you only have two, you could make it 20 then make it so there is a counter on how many are active. Each time the player fires, you initialize a new Fire object and increase the active counter up until the active counter is at max or max - 1 anyway.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: My first Game with ChilI Framework
Yeah i already do that. The problem is that when i press V to fire it fires all the ojects simultaneously. I found a way to avoid that by placing a bool inside the if statement of V and placing another if outside of the V if like this:
But this doesnt help if i want to fire more than 2 shots.
Edited by Albinopapa to use the code tags.
Code: Select all
if (wnd.kbd.KeyIsPressed('V') && fcount <= 2 && must == false)//Player Controls
{
if (fcount >= 0 && fcount < 2)
{
fcount1 = fcount;
player.inhibitV = true;
fire[fcount1].firex = player.x;
fire[fcount1].firey = player.y;
must = true;
}
if (fcount <= 1)
fcount++;
}
for (int y = 0; y < 1; y++)//Second Fire enable
{
if (fire[y].firey < 395)
must = false;
}
Edited by Albinopapa to use the code tags.
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: My first Game with ChilI Framework
What I do is create a firingdelay variable and a timecounter or framecounter variable, when the counter reaches the delay, allow user to fire next bullet by incrementing the activebulletcount.
pseudo code
increase framecounter
if V pressed and framecounter greater or equal to firingdelay
pseudo code
increase framecounter
if V pressed and framecounter greater or equal to firingdelay
- find first dead bullet in array ( either hit target or border )
- spawn new bullet at that index
- increase activebulletcount and
- reset framecounter
- kill bull
- decrease activebulletcount
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: My first Game with ChilI Framework
Thx for the replay i will try that.
Re: My first Game with ChilI Framework
I just finished tutorial 19 and as I go on I add what I learn into the code of the game.
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: My first Game with ChilI Framework
^^
That's a good way to do it.
That's a good way to do it.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: My first Game with ChilI Framework
I am at tutorial 20 now and added more things into the game, it looks nothing like before.
Re: My first Game with ChilI Framework
Now the game has 3 levels. I also added upgrades the grey squares increase fire number and the blue increace fire frequency.