Page 4 of 68

Re: Noob learns to code in 3 months

Posted: January 31st, 2017, 2:35 am
by Yumtard
THINK I came up with a solution, wrote it down on paper and will try it out tomorrow :D


Edit: Change of plans, can't sleep. Let's get to the bottom of this *flex*

Re: Noob learns to code in 3 months

Posted: January 31st, 2017, 3:53 am
by chili
Lol, I've been there. :)

Re: Noob learns to code in 3 months

Posted: January 31st, 2017, 4:13 am
by Yumtard
chili wrote:Lol, I've been there. :)
Feels like I'm adding a million functions to get this done :D will be a miracle if it works.

Re: Noob learns to code in 3 months

Posted: January 31st, 2017, 3:57 pm
by Yumtard
Hate to keep bothering for help but been clicking buttons, googling and debugging all night. Now I've got it so every third bullet hits but the other 2 goes right throught. No idea why

https://github.com/Yumtard/Spaceballs

maybe I should just go back a ton and redo most of it and do bullets some other way

Re: Noob learns to code in 3 months

Posted: January 31st, 2017, 5:19 pm
by Yumtard
SOLVED! Through manic starring at the code

Here was the issue

Code: Select all

for (int i = 0; i < nBullets; i++)
		{
			
			if (bullet[i].HasSpawned())
			{
				bullet[i].Update(dt);
			}

			if (hitTarget)
			{
				bullet[i].hasSpawned = false;
                                hitTarget = false;
			}
			
			
		}
So hitTarget becomes false for the second and third iteration. Moved "hitTarget = false;[/code]" to after the for loop and voila, works. My code feels a bit messy and there should be neater more simple ways to solve my problems, for example hasSpawned is public, but for now I'm just very happy it works

Re: Noob learns to code in 3 months

Posted: January 31st, 2017, 5:42 pm
by MrGodin
Was poking around your project, looks cool :). I did notice something that may be an issue

Code: Select all

void MineManager::Update(Ship& ship, float dt)
{
	for (int i = 0; i < nMines; i++)
	{
		if (mine[i].isActive())
		mine[i].Update(ship, dt);// here you check collision
		wasHit = mine[i].GotShot(ship, ship.GetnBullets());// here you check collision again
 	}
}
EDIT, i see you fixed it, good for you :)

Re: Noob learns to code in 3 months

Posted: January 31st, 2017, 8:14 pm
by albinopapa
https://github.com/albinopapa/Spaceballs

Here's some edits and additions that might help, it's not completely working yet, but maybe you'll get the idea and finish it up :)

Re: Noob learns to code in 3 months

Posted: January 31st, 2017, 8:15 pm
by albinopapa
Damn, you fixed it before I could finish

Re: Noob learns to code in 3 months

Posted: January 31st, 2017, 10:58 pm
by Yumtard
Gonna check it out in a minute guys! Really appreciate all the help you're giving.

Today has been a superbuggy day. Think i might be in over my head with this game.
Every time an issue is solved I get a new one.
This time I tried to make a shield for the ship. Visually it works but after the shield is gone the ship still wont take any damage.
Only thing I can think of is this:

in ship.cpp I have this

Code: Select all

Shield& Ship::GetShield()
{
	return shield;
}
then in mine.cpp I have this

Code: Select all

if (ship.GetShield().GetisActive() == false)
				{
					ship.Damage(damage);
				}

in shield.cpp I have this

Code: Select all

if (meterWidth == 0)
		{
			isActive = false;
		}
the starting value of isActive in shield.cpp is true.
In other words the ship shouldn't take damage while the ship is active, then when the meter runs out isActive should become false and the ship should start taking damage again.
but isActive doesn't seem to ever become false
The only thing I can think of is that I'm returning the actual class which has isActive set on true rather than returning the shield object from ship



edit: MIGHT have thought of a solution, 5% chance of working
edit 2: nvm, no clue

Re: Noob learns to code in 3 months

Posted: January 31st, 2017, 11:25 pm
by Yumtard
alrighty I see now I have Shield shield both in ShieldManager.h and in Ship.h which might cause trouble