Jump to content
  • Advertisement
Sign in to follow this  
fuchu

My fear...

This topic is 4725 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

My fear is getting busy in some other topic in C++ and fading from one. That is where the reference comes in right? Oh yeah, and physics. I fear of them to when I go for my breakout game. I just read the "For Beginners" section once again.

Share this post


Link to post
Share on other sites
Advertisement
Well, I can say from experience that aspects of it do not simply "fade away". For example, I read Andre's book on software rasterization, which is basically hardcore graphics theory, and I still remember almost all of the basic ideas that he laid out. Now granted, you will forget a few things like maybe a few function names and parameters, but the actual knowledge of what's going on will stick with you if you learn it well enough. In other words then, learn the actual theory behind a topic in games, not how to code it. If you know how to do something in theory, then coding it simply becomes finding out the function calls. References will help you figure this out (the DirectX SDK documentation for example).

As for physics, in games like breakout, you can easily just hack it using basic high school level math.
Heres an example:

You need to move the ball every frame by a certain velocity, in a certain direction.

Here's the math that will move the ball:

ballX += velocityX * cos( angleInRadians );
ballY += velocityY * sin( angleInRadians );

That's pretty easy physics, and you shouldn't get too buried in adding box collisions for the cubes.

Share this post


Link to post
Share on other sites
So those 2 lines are all I need? And I aint in highschool yet. I am trying to learn trig. though. I am in midschool. Trig is kinda hard though. Is it true I need calculus for First Person?

Share this post


Link to post
Share on other sites
You don't really even have to use trig, you could just break it up into two components so that you have:

Speed=10;
Vx=1;
Vy=1;
BallX+=Vx*Speed;
BallY+=Vy*Speed;

then on a collision just reverse the Vx and Vy components so that Vx*=-1; and Vy*=-1;

Like:

if(BallX<0||BallX+BallWidth>WindowWidth)
{
Vx*=-1;
}
if(BallY<0||BallY+BallHeight>WindowHeight)
{
Vy*=-1;
}

(Of course if you wanted the ball to leave the bottom then you wouldn't do the BallY+BallHeight>WindowHeight thing....)

Share this post


Link to post
Share on other sites
Quote:
Original post by shadowisadog
You don't really even have to use trig, you could just break it up into two components so that you have:

Speed=10;
Vx=1;
Vy=1;
BallX+=Vx*Speed;
BallY+=Vy*Speed;

then on a collision just reverse the Vx and Vy components so that Vx*=-1; and Vy*=-1;

Like:

if(BallX<0||BallX+BallWidth>WindowWidth)
{
Vx*=-1;
}
if(BallY<0||BallY+BallHeight>WindowHeight)
{
Vy*=-1;
}

(Of course if you wanted the ball to leave the bottom then you wouldn't do the BallY+BallHeight>WindowHeight thing....)


This just as a side note of this, don't reverse them both at the same time, or the ball will go back the same way. I've seen numerous pong and breakout clones that invert both at the same time.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!