Noob learns to code in 3 months

The Partridge Family were neither partridges nor a family. Discuss.
User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » January 31st, 2017, 2:35 am

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*

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Noob learns to code in 3 months

Post by chili » January 31st, 2017, 3:53 am

Lol, I've been there. :)
Chili

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » January 31st, 2017, 4:13 am

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.

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » January 31st, 2017, 3:57 pm

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

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » January 31st, 2017, 5:19 pm

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

MrGodin
Posts: 721
Joined: November 30th, 2013, 7:40 pm
Location: Merville, British Columbia Canada

Re: Noob learns to code in 3 months

Post by MrGodin » January 31st, 2017, 5:42 pm

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 :)
Curiosity killed the cat, satisfaction brought him back

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

Re: Noob learns to code in 3 months

Post by albinopapa » January 31st, 2017, 8:14 pm

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 :)
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

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

Re: Noob learns to code in 3 months

Post by albinopapa » January 31st, 2017, 8:15 pm

Damn, you fixed it before I could finish
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

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » January 31st, 2017, 10:58 pm

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

User avatar
Yumtard
Posts: 575
Joined: January 19th, 2017, 10:28 pm
Location: Idiot from northern Europe

Re: Noob learns to code in 3 months

Post by Yumtard » January 31st, 2017, 11:25 pm

alrighty I see now I have Shield shield both in ShieldManager.h and in Ship.h which might cause trouble

Post Reply