Noob learns to code in 3 months
Re: Noob learns to code in 3 months
That was it! Working shield now
Just gotta get a way to pick up the shield rather than starting out with it but I'll leave that for tomorrow.
For whatever reason I'm trying to solve issues for hours and then when I post about it I find a solution 20 minutes later
Just gotta get a way to pick up the shield rather than starting out with it but I'll leave that for tomorrow.
For whatever reason I'm trying to solve issues for hours and then when I post about it I find a solution 20 minutes later
Re: Noob learns to code in 3 months
Day 6
Alright so today was obv a bit crazy. programmed all night and all day. Ran into issues all the time and they all took a lot of time to get sorted out.
In the end managed to get bullets to collide with mines and to get a working shield.
Since I didn't do any math at all today I will have to do a bunch tomorrow. So plan for tomorrow is to take it a bit easy on the programming.
Programming goals for tomorrow:
Add objects you pick up to get the shield
Rewatch tut 18 and pay more attention.
IF adding objects to pick up goes smoothly (doubt it) I might also add a loc struct.
Alright so today was obv a bit crazy. programmed all night and all day. Ran into issues all the time and they all took a lot of time to get sorted out.
In the end managed to get bullets to collide with mines and to get a working shield.
Since I didn't do any math at all today I will have to do a bunch tomorrow. So plan for tomorrow is to take it a bit easy on the programming.
Programming goals for tomorrow:
Add objects you pick up to get the shield
Rewatch tut 18 and pay more attention.
IF adding objects to pick up goes smoothly (doubt it) I might also add a loc struct.
Re: Noob learns to code in 3 months
Holy damn the Spaceballs game looks and plays pretty fking good man. One suggestion though, to completely increase the "immersion" by like 9001%.
If there are bigger stars, that means that either:
1 :- They are bigger and/or
2 :- They are closer to the ship/player.
So, assuming 2 is true, you might want to have the big stars move faster, as the ship will be moving faster in respect to them.
I did it by just adding another function to the star class UpdateBig, and multiplying the dt by 3, although it might look better at a lower number. Hope this helps!
If there are bigger stars, that means that either:
1 :- They are bigger and/or
2 :- They are closer to the ship/player.
So, assuming 2 is true, you might want to have the big stars move faster, as the ship will be moving faster in respect to them.
I did it by just adding another function to the star class UpdateBig, and multiplying the dt by 3, although it might look better at a lower number. Hope this helps!
Re: Noob learns to code in 3 months
So far today I haven't gotten to any of my goals. As soon as I gave spaceballs a testplay i noticed that something felt a bit off with the bullets, I slowed down the bullets and the mines and noticed that sometimes nothing happened when trying to shoot and also if 1 bullet hit a mine then all bullets disappeared.
Spent a bunch of time on it and ended up with a solution that solved this issue 99%
I had this
Which ends up making it so if one bullet hits a mine then every single bullet in the array gets its hasSpawned turned to false.
I made a setter for hasSpawned and changed this function to a void like this
Like I mentioned this solved the issue to 99%, the only thing I notice now (in slowmotion) is that if I shoot 2 bullets that miss the mines and then the third bullet hits the mine, I can't shoot another bullet until one bullet goes off screen
Tried to fix it by just going
for (int i = 0; i < nBigStars; i++)
{
starB.Update(dt * 1.25f);
}
But the movement of the stars seemed laggy. Will look into it more a bit later.
Spent a bunch of time on it and ended up with a solution that solved this issue 99%
I had this
Code: Select all
bool Mine::GotShot(Ship & ship, int nBullets)
{
for (int i = 0; i < nBullets; i++)
{
const float bRight = ship.GetBullets()[i].GetX() + ship.GetBullets()[i].GetBulletSize();
const float bLeft = ship.GetBullets()[i].GetX() - ship.GetBullets()[i].GetBulletSize();
const float bBottom = ship.GetBullets()[i].GetY() + ship.GetBullets()[i].GetBulletSize();
const float bTop = ship.GetBullets()[i].GetY() - ship.GetBullets()[i].GetBulletSize();
const float mRight = x + width;
const float mBottom = y + height;
if (mRight >= bLeft &&
x <= bRight &&
mBottom >= bTop &&
y <= bBottom)
{
return true;
}
}
return false;
}
I made a setter for hasSpawned and changed this function to a void like this
Code: Select all
for..........
if (mRight >= bLeft &&
x <= bRight &&
mBottom >= bTop &&
y <= bBottom)
{
ship.GetBullets()[i].SetHasSpawned(false);
}
Thanks man! Glad you like it and great idea!gutrix_hd wrote:Holy damn the Spaceballs game looks and plays pretty fking good man. One suggestion though, to completely increase the "immersion" by like 9001%.
If there are bigger stars, that means that either:
1 :- They are bigger and/or
2 :- They are closer to the ship/player.
So, assuming 2 is true, you might want to have the big stars move faster, as the ship will be moving faster in respect to them.
I did it by just adding another function to the star class UpdateBig, and multiplying the dt by 3, although it might look better at a lower number. Hope this helps!
Tried to fix it by just going
for (int i = 0; i < nBigStars; i++)
{
starB.Update(dt * 1.25f);
}
But the movement of the stars seemed laggy. Will look into it more a bit later.
Re: Noob learns to code in 3 months
I fixed the issue slightly and know why it's not working 100%
if a series of 3 shots go like this
miss miss hit
and you try to shoot another bullet before the first one you shot goes off screen then it takes pressing the space bar 3 times
if the series goes
miss hit hit
then you have to press the spacebar twice to get a new bullet
so I'm guessing it's because of this FireBullet function:
because if you miss-miss-hit, then press spacebar again, you're back to index 0 which has already been spawned, space bar again and you're at 2 which has already been spawned and press again then it fires a bullet since index 3 isn't spawned
if a series of 3 shots go like this
miss miss hit
and you try to shoot another bullet before the first one you shot goes off screen then it takes pressing the space bar 3 times
if the series goes
miss hit hit
then you have to press the spacebar twice to get a new bullet
so I'm guessing it's because of this FireBullet function:
Code: Select all
if (shotsFired == false)
{
if (!bullet[bulletCounter].HasSpawned())
{
bullet[bulletCounter].Spawn(x + canonPos, y, dt);
gun.Play(0.5F, 0.5F);
}
++bulletCounter;
if (bulletCounter > 2)
{
bulletCounter = 0;
}
shotsFired = true;
Re: Noob learns to code in 3 months
Fixed the issue so it works just the way I want it to. It's not the pretties fix though
If there's a better way to do this that I'm too dumb to see, please let me know
Edit: I mean seems like this could be turned into a loop somehow..
edit 2: made it nicer by doing a loop with break
bullets working perfectly now so can finally move on for now
Code: Select all
void Ship::FireBullet(float dt)
{
if (shotsFired == false)
{
if (!bullet[bulletCounter].HasSpawned())
{
bullet[bulletCounter].Spawn(x + canonPos, y, dt);
gun.Play(0.5F, 0.5F);
}
else
{
++bulletCounter;
if (bulletCounter > 2)
{
bulletCounter = 0;
}
if (!bullet[bulletCounter].HasSpawned())
{
bullet[bulletCounter].Spawn(x + canonPos, y, dt);
gun.Play(0.5F, 0.5F);
}
else
{
++bulletCounter;
if (bulletCounter > 2)
{
bulletCounter = 0;
}
if (!bullet[bulletCounter].HasSpawned())
{
bullet[bulletCounter].Spawn(x + canonPos, y, dt);
gun.Play(0.5F, 0.5F);
}
}
}
++bulletCounter;
if (bulletCounter > 2)
{
bulletCounter = 0;
}
shotsFired = true;
}
}
If there's a better way to do this that I'm too dumb to see, please let me know
Edit: I mean seems like this could be turned into a loop somehow..
edit 2: made it nicer by doing a loop with break
Code: Select all
void Ship::FireBullet(float dt)
{
if (shotsFired == false)
{
for (int i = 0; i < 3; ++i)
{
if (!bullet[i].HasSpawned())
{
bullet[i].Spawn(x + canonPos, y, dt);
gun.Play(0.5F, 0.5F);
shotsFired = true;
break;
}
}
}
}
bullets working perfectly now so can finally move on for now
Re: Noob learns to code in 3 months
Day 7
Alright today was more fun!
Ended up programming more than planned due to the issue with bullets, but everything went smooth today.
1. Fixed bullet issue which improved game play
2. changed speed of stars with bigger stars moving faster than the small ones. You're totally right gutrix, improved immersion.
3. Made it so you can pick up a shield rather than starting out with one.
4. added sound effects for picking up hearts and shields and for when the shield disappears.
Starting to look like a game!
Ofc the number of objects like mines, hearts, shields and their placement will be different at the end but I imagine that's one if the last things I will deal with
Getting close to having to deal with enemy ships which I imagine will cause a great deal of confusion but will make it feel like a legit game.
Didn't have time to watch any chili vids Tomorrow I will! (and also try to make more time for stuff unrelated to programming)
Alright today was more fun!
Ended up programming more than planned due to the issue with bullets, but everything went smooth today.
1. Fixed bullet issue which improved game play
2. changed speed of stars with bigger stars moving faster than the small ones. You're totally right gutrix, improved immersion.
3. Made it so you can pick up a shield rather than starting out with one.
4. added sound effects for picking up hearts and shields and for when the shield disappears.
Starting to look like a game!
Ofc the number of objects like mines, hearts, shields and their placement will be different at the end but I imagine that's one if the last things I will deal with
Getting close to having to deal with enemy ships which I imagine will cause a great deal of confusion but will make it feel like a legit game.
Didn't have time to watch any chili vids Tomorrow I will! (and also try to make more time for stuff unrelated to programming)
Re: Noob learns to code in 3 months
Adding Title screen.
470k putpixel calls.
woops
470k putpixel calls.
woops
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Noob learns to code in 3 months
Yeah bro, you might be ready to look into loading images and memory allocations.
Check out chili's old tuts, somewhere around the beginner series lessons 16-17,19-21 and intermediate lessons 1 and 2
B16 -> Pointers
B17 -> Strings
B19 -> File access (read/write)
B20,B21 -> Loading bmp files ( B21 has a bug fix from B20) and load and render font sheets
I01 -> Memory management: Memory allocation on the heap and deallocation ( chili will show you an easier way for memory management in the new series )
I02 -> Using Windows GDI+ to load other image formats like .png
These 7 videos will take probably about 13 hours to watch, but they are worth it. You'll be able to get rid of all those PP calls and drastically reduce the compile time as well as the size of your code AND should make VS a lot more responsive.
Check out chili's old tuts, somewhere around the beginner series lessons 16-17,19-21 and intermediate lessons 1 and 2
B16 -> Pointers
B17 -> Strings
B19 -> File access (read/write)
B20,B21 -> Loading bmp files ( B21 has a bug fix from B20) and load and render font sheets
I01 -> Memory management: Memory allocation on the heap and deallocation ( chili will show you an easier way for memory management in the new series )
I02 -> Using Windows GDI+ to load other image formats like .png
These 7 videos will take probably about 13 hours to watch, but they are worth it. You'll be able to get rid of all those PP calls and drastically reduce the compile time as well as the size of your code AND should make VS a lot more responsive.
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
Re: Noob learns to code in 3 months
Thanks man!
I'm gonna take a break from spaceballs friday-sunday and just watch tutorials.
have a bunch of stuff to do this weekend so wont have time for spaceballs since I easily lose track of time and suddenly realize it's 4am
I'm gonna take a break from spaceballs friday-sunday and just watch tutorials.
have a bunch of stuff to do this weekend so wont have time for spaceballs since I easily lose track of time and suddenly realize it's 4am