[UPDATE 3.5]Angry Square

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
HippoSocks
Posts: 48
Joined: December 10th, 2012, 5:12 pm

[UPDATE 3.5]Angry Square

Post by HippoSocks » December 10th, 2012, 6:01 pm

Hey guys,

I'm new here so i thought i'd share my compilers poop with you,
This game is everything i've learn't from chilli in one game, kinda like revision.

I could of done many things better, but im lazy, and it's not a serious project after all...

The game has a basic options menu, which will allow you to turn the annoying sounds off if you wish.
Also the game uses "WASD" for control's, im planning on adding a switch between "WASD" and arrow keys, but, ehh effort...

Anyway, for those who try it i hope you enjoy. ;)

EDIT: I have updated the game, Some new things are:
- Rainbow apple. (God mode)
- Obstacles. (Spikes)
- Small bug fixes.

EDIT 2: I have added a few more features fixed some bugs.. The changes are:
- Sprite changes depending on what way the player is travelling ( Currently only left and right )
- Added text notifying when a perk is activated.
- Fixed bugs with spawning positions of apples being inside spikes ( Hopefully )
- Stopped the enemy spawning on top of the player. ( Works 90% of the time )

I have also almost finished adding the option to select what controls are used to move the player.

I have updated the attachment. Suggestions on what I can add are appreciated, because im stumped for ideas..
Hopefully this works as it should, It seems to work for me, but It's early hours in the morning, so if anything is broken I'll fix it once my brain works again. :lol:

EDIT 3: New update, new things! Fixed things! YAY! ;)

Okay some new things are:
- Enemy is harder to avoid.
- Enemy speeds up as your score increases ( Capped )
- Fixed a shed ton of bugs.
- Stopped apples spawning in spikes.
- Stopped spikes spawning on the player. ( Hopefully )
- Added new apple. ( Rotten/Bad apple )
- Removed safe zone. ( As a game play test )

The game is now in need of masses of optimizations.. :cry:
But it shall be done. ;)

Thanks to LuX and musi for the help with the "angle of direction" stuff, your a great help!

As per usual, I have attached the newer files to the post.

EDIT 3.5: Fixed the random crash bug.. Hopefully, if it happens to anyone, please let me know. ;)
Attachments
Angry Square 0.9b.zip
(123.57 KiB) Downloaded 415 times
Last edited by HippoSocks on December 19th, 2012, 11:05 pm, edited 5 times in total.
-Socks

User avatar
thetoddfather
Posts: 338
Joined: October 1st, 2012, 9:53 pm
Location: Canada

Re: Angry Square, Everything i've learn't in one game.

Post by thetoddfather » December 10th, 2012, 6:53 pm

Nice work mang! Very clean.

What pathfinding function did you use for buddy?

Your bonus/perk items do appear to not have random placement. Not sure if you intended for them always to show up in the top left of the screen or not.

You should add perks for speed increases, and increment buddy's speed via score. So if you're a lazy gamer and don't get the perk apples you'll pay for it in the long run. That would add a little extra strategy, but keep the existing perks too.

Anyway. I like it. This one kept my attention :)

User avatar
thetoddfather
Posts: 338
Joined: October 1st, 2012, 9:53 pm
Location: Canada

Re: Angry Square, Everything i've learn't in one game.

Post by thetoddfather » December 10th, 2012, 6:56 pm

Just thinking here, or add levels based on score or num of apples collected would be another way. With each level buddy gets a little tougher. And if you felt a little ambitious, add eyeball right/left/up/down sprites so you and buddy look in the direction their going ;)

HippoSocks
Posts: 48
Joined: December 10th, 2012, 5:12 pm

Re: Angry Square, Everything i've learn't in one game.

Post by HippoSocks » December 10th, 2012, 7:25 pm

Thanks for the positive feedback man!

It did take some time, I'm planning on adding more features, like more perks/power ups..

But as for my "buddy" the code for that is pretty basic.. it was more advanced but the game got to easy,

Code: Select all

if(EnemyX < PlayerX)
{
	EnemyVelocityX = 1.5f;
} else if( EnemyX > PlayerX)
{
	EnemyVelocityX = -1.5f;
} else { EnemyVelocityX = 0; }

if(EnemyY < PlayerY)
{
	EnemyVelocityY = 1.5f;
} else if(EnemyY > PlayerY)
{
	EnemyVelocityY = -1.5f;
} else { EnemyVelocityY = 0; }
As for the apples locations, i used:

Code: Select all

	GoalX = rand() % 764 + 2;
	GoalY = rand() % 499 + 2;
I had this set for every time the Player picks a red apple,
to randomly place them, but i couldn't think of a way to stop it spawning right up in that top corner.
The same was done for red apples to, so it should of spawned randomly in the window some place..

The menu system is also to messy to read, if i had better knowledge of pointers it would of been cleaner.

As for levels, that was an option, but i wanted it to randomly create a map once the players score reached a certain number, and have 2 more walls added each time, and once level 4 or so is reached the enemy wouldn't have collision with the walls but the player still would, to add more of a challage..
But i removed all of the code for this as it got to the point where it would just plonk them anywhere.

If i get around to making the source tidy and removing unsed and messy code, i will upload it aswell, but for now, even i have issues reading it.. :lol:

On a last note, that idea about moving eyes, i believe it would be possible to use the circle code chilli shown us ages ago to make a "track" for a the eye to follow, there might be a easier way to do it, but i do think that having a black dot follow the circle round could have more detail that just a few set positions or a few preset sprites..
-Socks

User avatar
thetoddfather
Posts: 338
Joined: October 1st, 2012, 9:53 pm
Location: Canada

Re: Angry Square, Everything i've learn't in one game.

Post by thetoddfather » December 10th, 2012, 9:07 pm

Hmmm, if I understand you correctly, and I may not, you might want to make a seperate PerkX and PerkY with their own rand() number generators that are only refreshed in the even of player picking them up.

Menu shmenu. It's all about the game I say. The menu is great and serves its purpose. I'd focus on gameplay tweaks if I were you.

Hmmm, that is an interesting thought adding blocks every level as obstacles, but preset locations slowly building a maze would be as fun as random in some ways too, and you wont get 'boxed in', pun intended. Perhaps a set bunch of locations that in time make a maze for the player to work through. Having buddy be free from those limits would certainly ramp up the difficulty. Maybe adding a couple of new ideas for fun perks too like 'no collision' apple, allowing you to slip through walls temperarily. Delicious.

User avatar
thetoddfather
Posts: 338
Joined: October 1st, 2012, 9:53 pm
Location: Canada

Re: Angry Square, Everything i've learn't in one game.

Post by thetoddfather » December 10th, 2012, 9:27 pm

Could make an array of structs of preset locations and have a random number generator chose the location each level.

Code: Select all

#define MAXLOC 2
	struct Loc
	{
		int x;
		int y;
		bool hasPlaced;
	};
	
	Loc L[2];
	L[0].x = 20, L[0].y = 20, L[0].hasPlaced = false;
	L[1].x = 40, L[1].y = 20, L[1].hasPlaced = false;
	int numLoc;
	if(appCollected == 10)
	{
		level++;
		appCollected = 0;
		if(numLoc <= MAXLOC)
		{
			int locSel = rand() % 2;
			while(L[locSel].hasPlaced == true)
			{
				locSel = rand() % 2;
			}
blah blah place block at L[locSel]
L[locSel].hasPlaced = true;
			numLoc++;
		}
	}
I have not had enough coffee to take responsibilty for the above code lol. My brain isn't in the game at the moment, but that might be a direction you could take for block placement.

HippoSocks
Posts: 48
Joined: December 10th, 2012, 5:12 pm

Re: Angry Square, Everything i've learn't in one game.

Post by HippoSocks » December 10th, 2012, 10:57 pm

I like the idea, I could have it build a map as it goes along, but i am still very new to C++, only been working with it about 3 months, and most of that has been fail's and breaking stuff, so that would be a challenge i would have difficulty facing..

I will start planning for map idea's and work on the graphics, the biggest problem i will face will be making sure the apples don't spawn inside the walls, that'll be a major problem for the game play, and it could take a while to get the apples to spawn, with all the walls, because of how i have set it up, unless i make a timer to make the player wait for a new apple..

Saying that i would be able to use it to add more difficulty..

if guess i could use:

Code: Select all

if(wallPlaced[index] == true)
{
	if(/* player collision detection stuff */)
	{
		// Stop player going through it stuff
	} 
	if(/* apple & wall collision */)
	{
		// respawn apple again :(
	}
}
This way i can hard code maps and make them be randomly selected, or level select ?
But i am assuming performance could drop using this method, though.

I also like that tasty idea about the no collision apple.
I would personally make it a rare spawn, since all perks have different chances of spawning,
Blue - 20 in 120
Pink - 15 in 120
Orange - 19 in 120
These still need tweaking though.

Hopefully I made some sense their, it's hard to think when half asleep.
Im just working on small bug fixes for the time being though.
-Socks

User avatar
thetoddfather
Posts: 338
Joined: October 1st, 2012, 9:53 pm
Location: Canada

Re: Angry Square, Everything i've learn't in one game.

Post by thetoddfather » December 10th, 2012, 11:40 pm

That's another good reason to have predefined locations for your walls. Then it would be fairly easy to keep track of since you could run through all hasPlaced == trues when checking for an apple location. But yah, walls certainly will add a lot of work for ya, and if you're just starting out I would just keep playing with speed/difficulty incriment and perks for now.

I think there's lots of room to add fun without even thinking about adding walls.

HippoSocks
Posts: 48
Joined: December 10th, 2012, 5:12 pm

Re: [UPDATE]Angry Square, Everything i've learn't in one gam

Post by HippoSocks » December 11th, 2012, 9:39 pm

I had a few attempts at walls, but failed, i couldn't get collision right and worked at it a few hours, so i thought over the idea, and thought, "Things that hurt, makes things hard..." and that lead to me adding spikes that spawn as the score increases..

It adds more fun to the game, by adding a small challenge, hopefully the spikes aren't to cluttered..

I added a new apple as well, in place of the one that would allow the player to move through the walls, I added one that will give the player "God mode" untill the next red apple is picked, i should be swapping this to a timer of some sort soon, if i find it a better idea.

I had a try at making the sprites change depending on what direction they are facing, which i believe you also suggested, but the sprites looked gross and gave some strange graphical glitch, so untill i fix that its commented out.

PS: I ment to send this a while ago, but seem's i forgot to press submit :lol:
-Socks

User avatar
thetoddfather
Posts: 338
Joined: October 1st, 2012, 9:53 pm
Location: Canada

Re: [UPDATE]Angry Square, Everything i've learn't in one gam

Post by thetoddfather » December 13th, 2012, 12:19 am

Nice work! Took me awhile to get the godmode apple :p but once I did I ran right up in buddy's face and told him where to go. I see the bonus apples are generating away from the top left now, but in the short time I played they still don't seem randomly generating a proper location. I could be wrong there.

My suggestions at this point other than the speed increases for you and buddy would be to take out the safe zone, have spikes generate a little more often perhaps too. Maybe add a sound for when you're taking damage too would be nice :)

For some reason, the Jaws theme music comes to mind for BGM hahaha.

Post Reply