Page 1 of 1

My first Game with ChilI Framework

Posted: July 24th, 2017, 8:56 pm
by Aizenvolt
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.

Re: My first Game with ChilI Framework

Posted: July 25th, 2017, 5:13 am
by albinopapa
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.

Re: My first Game with ChilI Framework

Posted: July 25th, 2017, 9:21 am
by Aizenvolt
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:

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;
			}
But this doesnt help if i want to fire more than 2 shots.

Edited by Albinopapa to use the code tags.

Re: My first Game with ChilI Framework

Posted: July 25th, 2017, 10:04 am
by albinopapa
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
  • find first dead bullet in array ( either hit target or border )
  • spawn new bullet at that index
  • increase activebulletcount and
  • reset framecounter
When a collision happens,
  • kill bull
  • decrease activebulletcount
You might break things down into functions instead of having all the logic right in one function. This will help keep things in perspective.

Re: My first Game with ChilI Framework

Posted: July 25th, 2017, 11:31 am
by Aizenvolt
Thx for the replay i will try that.

Re: My first Game with ChilI Framework

Posted: July 31st, 2017, 7:36 pm
by Aizenvolt
I just finished tutorial 19 and as I go on I add what I learn into the code of the game.

Re: My first Game with ChilI Framework

Posted: July 31st, 2017, 8:39 pm
by albinopapa
^^
That's a good way to do it.

Re: My first Game with ChilI Framework

Posted: August 6th, 2017, 9:17 am
by Aizenvolt
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

Posted: August 14th, 2017, 6:20 pm
by Aizenvolt
Now the game has 3 levels. I also added upgrades the grey squares increase fire number and the blue increace fire frequency.