Public Group

#### Archived

This topic is now archived and is closed to further replies.

# BreakOut clone with source

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

## Recommended Posts

Check out my simple GDI BreakOut (VazBreak) in plain C What this shows a beginner how to do simple Windows setup (WinProc and WinMain) simple GDI (full screen) graphics (rectangles only) simple Game Loop and game states (based on Lamothe, I like his style) simple collision detect (paddle/blocks) fully commented source Game Notes
VazBreak.cpp
Game EXE

www.bringyou.to/games Next up....Vazteroids.... I want to see how much I can do with GDI only. PhilVaz

##### Share on other sites
a little tip, use trig to move the ball instead of the cheap old "increase x speed to change angles". given a ball angle ''a'' this is how much to move the ball in each axis:

x += sin(a) * speed;
y += cos(a) * speed;

speed is how fast the ball is going, a is the angle, x and y are the ball''s position. x and y have to be floats though

##### Share on other sites
Cool, but you can''t use the keyboard and mouse right after eachother, and it''s almost impossible with the keyboard.

-~-The Cow of Darkness-~-

##### Share on other sites
<< x += sin(a) * speed; y += cos(a) * speed; >>

BillyBob >> speed is how fast the ball is going, a is the angle, x and y are the ball''s position. x and y have to be floats though >>

Interesting, didn''t think of that. I''m a beginner myself, but have had high school/college trig. With Vazteroids I want a way to rotate the asteroid points in space, looks like trig is the way to go.

Cows >> Cool, but you can''t use the keyboard and mouse right after eachother, and it''s almost impossible with the keyboard. >>

True, suggestions on how to fix that? I think it has to do with setting "focus" to the game window or something. If you click the mouse button, you can move with keys. And it is more difficult with keys. Tried to set the ball at a good pace, it speeds up much when you hit the red row.

Phil P

##### Share on other sites
But what is wrong with using the cheap trick way to move the ball??

Is the trig version more accurate or what? (I haven''t used trig yet..)

##### Share on other sites
looks great. The only suggestion I would make is to make it so the ball can never move straight up and down/side to side. Other than that, great job

##### Share on other sites
julien >> Is the trig version more accurate or what? (I haven't used trig yet) >>

Trig version is probably more accurate and is one line rather than multiple IFs which I used. You can get a precise deflection using sin/cos. Both methods would work I assume.

evillive >> looks great. The only suggestion I would make is to make it so the ball can never move straight up and down/side to side. >>

Good point, otherwise the person can let the game sit there forever. I might change it.

Thanks for the input. I'm gonna do a Vazteroids then maybe a Pacman (Vazman?). No C++, no classes, no linked lists, no DirectX, just straight C and GDI. Keeping it simple as possible for now.

Phil P

[edited by - PhilVaz on April 21, 2003 9:38:59 PM]

##### Share on other sites
Just wanted to say nicely done, source code was a breeze to follow. You might want to put the collision detection in a function by itself for a cleaner structure but overall nice.

As to the game itself my only complaint would be the paddle collision detection is a bit off, probally the Y cordinate thing since I only had a problem when going for a paddle side angle shot.(E.G hitting ball with side of paddle vs top line of it, increaseing your Y collison about 2 or 3 pixels would probally fix that, just a thought.) Of course you may have intended it to be that way in which case what do I know

[edited by - zenroth on April 22, 2003 1:11:15 AM]

##### Share on other sites
<< Just wanted to say nicely done, source code was a breeze to follow. >>

Thanks, I think I'll stick with the easy to follow plain C until I get into DirectX in a few months.

<< You might want to put the collision detection in a function by itself for a cleaner structure but overall nice. >>

I could, if it was called more than once. It would only be called inside GameMain, so I did it there without a function. GameMain was kinda long I admit.

This is a really good board. You get a lot of help and interaction quickly.

Next up, Vazteroids. I found a good Geocities page that explains the math and what's involved in doing an asteroids clone in Java. I'm gonna use this to do one in C.

Asteroids in Java

Phil P

[edited by - PhilVaz on April 22, 2003 2:27:03 AM]

##### Share on other sites
quote:
Original post by PhilVaz
Thanks, I think I'll stick with the easy to follow plain C until I get into DirectX in a few months.

Hehe directx can be easy to follow as well as long as you hide it all into nice little functions.
quote:

I could, if it was called more than once. It would only be called inside GameMain, so I did it there without a function. GameMain was kinda long I admit.

True guess when I moved from C to C++ I started to like BlackBoxing,software engineering and Classes way to much.
Still pains me that my copy of Code Complete is 2800 miles away.
quote:

This is a really good board. You get a lot of help and interaction quickly.

Aye that it is and has always been, I should spend more time here really.

Anyways good luck on the astroids clone

[edited by - zenroth on April 22, 2003 12:12:16 PM]

[edited by - zenroth on April 22, 2003 12:13:47 PM]

1. 1
2. 2
Rutin
20
3. 3
khawk
16
4. 4
A4L
14
5. 5

• 11
• 16
• 26
• 10
• 11
• ### Forum Statistics

• Total Topics
633756
• Total Posts
3013707
×