Page 5 of 7

Re: C++ Progress ish

Posted: June 17th, 2017, 3:14 pm
by Yumtard
Oh I saw that game on chilis update.
Looks dope! Well done

Re: C++ Progress ish

Posted: June 17th, 2017, 4:21 pm
by chili
ceofil wrote:What's the best way to aproch this kind of stuff? Try to do it on your own ( and probably spend a lot of time on it) or search and use a method that is already tested and it's more efficient and all?
Definitely search and research and find algorithms. Don't reinvent the wheel; it takes a lot of time and the results aren't gonna beat what humanity has already produced. You can learn some skills by implementing stuff like that from scratch, but researching and implementing existing algorithms is also a super important (probably more important) skill that needs to be exercised early and often. And also you wanna get shit done.

Re: C++ Progress ish

Posted: June 20th, 2017, 5:50 pm
by ceofil
Where I'm at so far.
This is like a demo or something. Just added a bunch of enemies and some wall for a "playable" level.
I plan on adding a level editor like in the tanks game but now it will be saving and loading levels from files. Also change the AI to be a little more responsive for what's happening around. Probably change the graphics too.

Re: C++ Progress ish

Posted: June 24th, 2017, 5:23 pm
by ceofil
Hi there!
Finished the level editor...kind of. Still have to figure out why when loading the level all the angles are set to 0. Also want to make it so you can load and save multiple levels and change the interface so it fits more levels.
There is already a level in there. load -> level editor -> implement to play it.

screenshot
github

Any feedback is appreciated.

Re: C++ Progress ish

Posted: June 24th, 2017, 5:57 pm
by Zedtho
Just a quick question, how far into the tutorials are you? That seems like some advanced stuff, and I'd like to help you with this , so wanted to know if I could.

Re: C++ Progress ish

Posted: June 24th, 2017, 5:59 pm
by ceofil
The last tutorial I've watched is Intermediate 4.

Re: C++ Progress ish

Posted: June 24th, 2017, 7:18 pm
by albinopapa
Did you know?

instead of the slow length <= radius

Code: Select all

	for (int i = 0; i < nOtherBullets; i++)
	{
		if (otherBullets[i].IsSpawned())
		{
			if (Vec2(otherBullets[i].GetPosition() - pos).GetLength() <= radius )
			{
				alive = false;
				otherBullets[i].Destroy();
			}
		}
	}
You can check for LengthSq <= radiusSq

Code: Select all

	// Calculate square radius outside of loop to avoid recalculating each iteration.
	const auto radiusSq = radius * radius;
	for (int i = 0; i < nOtherBullets; i++)
	{
		if (otherBullets[i].IsSpawned())
		{
			if (Vec2(otherBullets[i].GetPosition() - pos).GetLengthSq() <= radiusSq )
			{
				alive = false;
				otherBullets[i].Destroy();
			}
		}
	}
This avoids having to do the square root each iteration of the loop.

Re: C++ Progress ish

Posted: June 24th, 2017, 7:26 pm
by albinopapa
Instead of using hex codes for char keys, I would suggest using the literals; 'W', 'S', 'A', 'D'. The reason being it is way easier to tell at a glance those are the keys you are meant to push.

Code: Select all

	if (kbd.KeyIsPressed('W'))
	{
		delta.y = -1.0f;
		movementHappened = true;
	}
	else if (kbd.KeyIsPressed('S'))
	{
		delta.y = 1.0f;
		movementHappened = true;
	}
	if (kbd.KeyIsPressed('A'))
	{
		delta.x = -1.0f;
		movementHappened = true;
	}
	else if (kbd.KeyIsPressed('D'))
	{
		delta.x = 1.0f;
		movementHappened = true;
	}
This way, you or anyone else won't have to look up char codes to know which letter/number/symbol you are trying to use. If I got the order wrong or incorrect keys here, it's because I didn't want to look the hex codes up.

I like the code layout, it's pretty clean, keep up the good work.

Re: C++ Progress ish

Posted: July 1st, 2017, 5:01 am
by chili
Yeah, definitely use the char literals when you can.

Re: C++ Progress ish

Posted: July 18th, 2017, 7:56 pm
by ceofil
Well, well, well...
What happened in the past few weeks? Not that much...at least for me.

Changed the level selection menu in the super hotline miami game.
Edit: found these http://imgur.com/a/G8eJu

Watched the old B19 tutorial for loading sprites but then I watched a few more. Nothing much, just tryna make it work. Added a little something something. Functions to make a sprite black&whie, threshhold, invert...just for fun. Maybe I'll use them later when a character dies draw him black and white, or when it takes damage draw it with threshhold.
Spoiler:

Code: Select all

	void Desaturate() 
	{
		int newValue = ( GetR() + GetG() + GetB() ) / 3;
		*this = Color(newValue, newValue, newValue);
	}
	void ThreshHold(int value)
	{
		assert( value >= 0 && value <= 255 );
		int average = (GetR() + GetG() + GetB()) / 3;
		if ( average < value )
		{
			*this = Color(0,0,0);
		}
		else
		{
			*this = Color(255,255,255);
		}
	}
	void Invert()
	{
		int r = 255 - GetR();
		int g = 255 - GetG();
		int b = 255 - GetB();
		*this = Color( r,g,b ); 
	}
And then do that for every pixel in the surface except the key.

Then continued with the old series ( B19 - I6 ). Great stuff. I4 was a very good watch even tho I might not have understood everything, it gives a pretty good idea about how things works.
Made the chaos game. It's still a very simple version of it with hard coded numbers and the points can't be moved.
Spoiler:
Image
Homework for current I6.

Good times, good times.