Drawing Rectangles and my future BREAKOUT game in Windows GDI, I hope.

Started by OceanJeff32, September 21, 2005, 08:19:18 AM

Previous topic - Next topic

OceanJeff32

Just thought that I would display my latest graphics project, I put a link to my web site on here, and last night my site got about a dozen or more hits, so I assume people are interested in my work!  That's cool.

I'm working on making this attached program (the source and .exe are included) into a playable breakout game.

Any help would be appreciated, but I am going to release the game as freeware, in the basic version, that is, no graphics, just colored rectangles, etc.

Take a look, any feedback, positive or negative would help.

Thanks,

Jeff C
:U

3am UPDATE! The other program that I had on here, was FLAWED, imagine that...a programmer making a program that crashes!!! HAHA, anyways, this new one won't and it's because of the cmp eax, 1 lines in the code.  The boundaries were set to low, when the computer attempts to draw the rectangle when the y coordinate is 0, CRASH, sorry, but the update is the new attachment.

ALSO, for you beginners, this new code contains the debugging code I used to figure out the problem.  I don't use a debugger, yet...
:boohoo:

[attachment deleted by admin]
Any good programmer knows, every large and/or small job, is equally large, to the programmer!

Mincho Georgiev

Something that i've done without MMX :)
Thank you for reply!
:U

[attachment deleted by admin]

OceanJeff32

Awesome job!  I like the bitmap animation, it's such simple code.  I appreciate it very much, I will have to look it over.
:U :U (two thumbs up here)
My latest has a few changes:

1) no mmx and sse2 test...for some reason, these times it didn't work right for me, i will update it in future re-visions.

2) the ball is smaller and bounces around the screen alright, but it doesn't exactly bounce around the block in the middle of the screen, check it out, any help would be appreciated, but I am going to work on it tonight, i'm the graveyard shift at the hotel tonight, so guess who has a few hours to work on masm...ME!

later guys,

jeff c
:bdg (it's okay to laugh at your failures...that's how we stand back up!)

[attachment deleted by admin]
Any good programmer knows, every large and/or small job, is equally large, to the programmer!

OceanJeff32

I feel like i'm making a blog of my breakout. :red

Fixed the collision detection, but only by changing the velocity to one either way!  This will change later, but for now, I move on...NEXT!
:wink

2nd Update in a row here: I made the collision detection perfect (haha) by checking that the ball NEVER enters the block. I was previously just checking (startx,starty) which was the northwest corner of the ball, now I added the (startx + lenx, starty + leny) into two of the checks.  I don't think there is a more efficient way to check for this collision, but I will keep working on this project throughout the night.

3rd Update (amove4b.zip): Optimized? the code size, by combining the four checks into just two not so larger checks, I figured that they shared the same code after the ball boundaries were checked with either x or y, so I concatenated, and added a label...well, you'll see the difference between the two files.  For beginners the differences should prove enlightening.

:cheekygreen:
later,

jeff c
:dance: (I'm happy camper now, the graveyard was worth it just for that update)

[attachment deleted by admin]
Any good programmer knows, every large and/or small job, is equally large, to the programmer!

gabor

Good work Jeff!


I have a question: I see you were using gdi. Does it has any use to code directly with directx functions? Or the gdi is just a wrapper for those rutines? Frankly, I don't know this gdi stuff.

Another thing: the collision detection is a very delicate thing. When rectangular shapes are used it is not very hard to solve, but shapes with curves can not be collision detected via the coordinate method. Do you have an idea for this?

Greets, Gábor

Mincho Georgiev

Thanks ,OceanJeff32! I'll look over your code. I had see that you're corected the movie (4th). If you ask me,the best sollution for your project is:
1st - when the window's rect's is changed - the red square's rect's to be changed as well (i.e. centered on the screen in different size).
2nd -for  the ball to continue the same movement in the new rect's.
------

Excuse my bad endlisg,i hope you understanding my point. I'll be glad if i can help you.
BTW - in the next edition of my example ,i will emulate an ball impact between the 2 balls (when i had a necessary free time to do that - i work too  :bg )

Bye for now!

OceanJeff32

I do have a program in direct x (a breakout program) using .PNG files I think...This program that I made just uses a simple DIB (Device Independent Bitmap) and draws to the memory context (off-screen) and then displays it to the video display context. 

http://msdn.microsoft.com

The above link is great information on all the functions for Windows API and GDI is included. GDI means Graphics Device Interface, and just means a set of functions that windows knows ahead of time, so you don't re-create the wheel.  Although that's what I did with the rectangle drawing...lol

Direct X is a bit more complicated to program in, so I've only worked with Direct X and C/C++, you have to expose the COM interfaces and work that way with surfaces, and other things...

Direct X is awesome, and the SDK (software developer's kit) is available for FREE from microsoft also!

I am trying to figure out what to do next with my breakout demo, I'm learning as I go along.

Oh how easy this was to learn in JAVA!!! (and Direct X)

Later guys,

Jeff C
:bg
Any good programmer knows, every large and/or small job, is equally large, to the programmer!

OceanJeff32

Oh, and on collision detection for irregular shapes, a lot of texts recommend bounding volumes...these can simulate a fairly good collision.

There are some good algorithms to detect a circular bounding volume, I will find one and try it out on here, when I start to become more advanced.  If you search Andre LaMothe and bounding volumes on google.com, I'm not sure what you'll get but one of those terms could lead you to a solution.

I'll investigate further, and get back to you,

Jeff C
:P
Any good programmer knows, every large and/or small job, is equally large, to the programmer!