My first Game with ChilI Framework

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
Aizenvolt
Posts: 6
Joined: July 24th, 2017, 8:23 pm

My first Game with ChilI Framework

Post by Aizenvolt » July 24th, 2017, 8:56 pm

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.
Last edited by Aizenvolt on August 14th, 2017, 6:18 pm, edited 1 time in total.

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: My first Game with ChilI Framework

Post by albinopapa » July 25th, 2017, 5:13 am

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.
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

Aizenvolt
Posts: 6
Joined: July 24th, 2017, 8:23 pm

Re: My first Game with ChilI Framework

Post by Aizenvolt » July 25th, 2017, 9:21 am

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.

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: My first Game with ChilI Framework

Post by albinopapa » July 25th, 2017, 10:04 am

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.
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

Aizenvolt
Posts: 6
Joined: July 24th, 2017, 8:23 pm

Re: My first Game with ChilI Framework

Post by Aizenvolt » July 25th, 2017, 11:31 am

Thx for the replay i will try that.

Aizenvolt
Posts: 6
Joined: July 24th, 2017, 8:23 pm

Re: My first Game with ChilI Framework

Post by Aizenvolt » July 31st, 2017, 7:36 pm

I just finished tutorial 19 and as I go on I add what I learn into the code of the game.

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: My first Game with ChilI Framework

Post by albinopapa » July 31st, 2017, 8:39 pm

^^
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

Aizenvolt
Posts: 6
Joined: July 24th, 2017, 8:23 pm

Re: My first Game with ChilI Framework

Post by Aizenvolt » August 6th, 2017, 9:17 am

I am at tutorial 20 now and added more things into the game, it looks nothing like before.

Aizenvolt
Posts: 6
Joined: July 24th, 2017, 8:23 pm

Re: My first Game with ChilI Framework

Post by Aizenvolt » August 14th, 2017, 6:20 pm

Now the game has 3 levels. I also added upgrades the grey squares increase fire number and the blue increace fire frequency.

Post Reply