adv lesson 10
Re: adv lesson 10
Great minds think alike I would say
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: adv lesson 10
lol, must have updated around the same time.
I agree.
I agree.
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: adv lesson 10
Hello again! I have a new problem I'm trying to get the collison to work and not getting anywhere,
I thought it was just going to be super simple because all the implementation is all there I just have to call it.
What I've done so far:
I made a super simple DrawCircleClip function that works fine.
Bullet inherits from collidablecircle and implements all the function from it.
I call the collision function on the map in the UpdateModel function like this
I thought for sure this was going to work but my "bullets" just pass trough the walls all the same.
Do you have any ideas?
all help welcome I'll include my project in case someone wants to look at it.
I thought it was just going to be super simple because all the implementation is all there I just have to call it.
What I've done so far:
I made a super simple DrawCircleClip function that works fine.
Bullet inherits from collidablecircle and implements all the function from it.
I call the collision function on the map in the UpdateModel function like this
Code: Select all
for (Bullet &x : ship.GetBullets())
{
map.HandleCollision(x);
}
Do you have any ideas?
all help welcome I'll include my project in case someone wants to look at it.
- Attachments
-
- Simple_space_game_v1.1.zip
- (270.02 KiB) Downloaded 101 times
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: adv lesson 10
Ok, so my initial findings is that calculating velocity by angle every frame isn't going to work. The rebound changes velocity, but then the velocity is recalculated by angle, which is still in the direction before the collision.
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
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: adv lesson 10
Ok, so found your second problem. The GetBullets() function, returns a copy of the vector instead of a reference to the vector of bullets.
Needs to be like this:
Needs to be like this:
Code: Select all
vector<Bullet> &GetBullets()
{
return bullets;
}
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: adv lesson 10
AWESOME!! thank you man! the damn refrence vs copy always gets me, one of these days I'll remember to but "&" there hahaha.
what I did:
I calculated the velocity sepret from the update funtion and then just added the velocity to the posistion in the update function.
And of course put the damn refrence operator on the getbullets function like you said and it works beautifully.
I can shoot out all the little bubbles I want and it doesn't even lag. This is awesome.
Next on the agenda is I think figuring out the collision with the ship. It looks simple when I think about it in my head but I'll prebubly be back here asking for help again in no time.
Again thank you so much for the help. Until next time
(if someone wants to try and take this on and do something with it just leave a replay here and I'll post my project here for you guys to have fun with)
what I did:
I calculated the velocity sepret from the update funtion and then just added the velocity to the posistion in the update function.
And of course put the damn refrence operator on the getbullets function like you said and it works beautifully.
I can shoot out all the little bubbles I want and it doesn't even lag. This is awesome.
Next on the agenda is I think figuring out the collision with the ship. It looks simple when I think about it in my head but I'll prebubly be back here asking for help again in no time.
Again thank you so much for the help. Until next time
(if someone wants to try and take this on and do something with it just leave a replay here and I'll post my project here for you guys to have fun with)
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: adv lesson 10
Something I don't know if you have implemented, is deleting the bullets. Erasing the vector elements can be as simple as bullets.erase(iterator); where iterator is the offset from the beginning of the vector. Also, there is another way that is more efficient if you don't need the order of the vector to be preserved.
Since erasing an element in the beginning of the list causes all the elements to be copied down, element[1] get copied to element[0] and so on to the end of the vector, it's more efficient to just copy the last element of the list to the spot you want to erase, then erase the last element in the list. That way there is only one copy and one erase instead of 1 erase and several copies.
Since erasing an element in the beginning of the list causes all the elements to be copied down, element[1] get copied to element[0] and so on to the end of the vector, it's more efficient to just copy the last element of the list to the spot you want to erase, then erase the last element in the list. That way there is only one copy and one erase instead of 1 erase and several copies.
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