Skip to main content
gamedev.net
🔒 Locked

Hardball

Started by pdstatha Jul 21, 2002 at 5:53 AM 6 replies 900+ views
Original Post
pdstatha
pdstatha
After succesfully completing my Towers of Hanoi DOS based game, I am now going to move onto a hardball(bouncing a ball of the blocks) clone. One thing immediately pops to mind though, is how do I do the bouncing stuff, i.e. calcualting the speed and angle the ball will bounce off at?? Also can someone explain virtual functions, their a slightly new concept to me and I can''t say I understand them yet.
elis-cool
elis-cool
I suggest you start with pong, then move onto the breakout style game. Many begginers, including myself, thinkyou need angles eg sin, cos in 2D when in fact in 90% of cases you dont. You use x and y velocitys, eg an x velocity of say 2 and y of 2 would give you an angle of 45. You would update this every frame etc.
eg: ball.Xpos += ball.Xvel; and same for the y. Note this is in pixels. If you want frame rate independant motion, you would go something like so: ball.Xpos += ball.Xvel*(1.0f/FPS); note that is is in floats, and is measured in pixels a second, were as the other way was pixels a frame.
Hope I helped.

CEO Platoon Studios
[email=esheppard@gmail.com]esheppard@gmail.com[/email]
pdstatha
pdstatha
Thanks that makes sense.

Next question, I plan to load level maps from a pre-determined pattern of blocks eg. from a bitmap file. How would I distinguish between each block in the bitmap, so that when it is loaded, individual blocks could be removed????
cozman
cozman
In Zero Bricks (my Breakout game: http://www.conceptofzero.com/downloads/ZB08.zip) I loaded the array of bricks from a text file (you can do something as simple as 0 for no brick and 1 for brick) Then it went through the array and drew the bricks from a bitmap file storing all my brick images. There is no easy way to take a single bmp file and tell where the bricks are.
pdstatha
pdstatha
I quite like that idea cozman, just to confirm it though, how did that work Out? I mean what was your resolution set at.

I.e. if the res was 800*600 would you have a mixture of 0''s + 1''s 800 across and 600 down???

That sounds dumb, but then again thats probably me interpreting you incorrectly.
terminate
terminate
quote:
Original post by pdstatha
I quite like that idea cozman, just to confirm it though, how did that work Out? I mean what was your resolution set at.

I.e. if the res was 800*600 would you have a mixture of 0''s + 1''s 800 across and 600 down???

That sounds dumb, but then again thats probably me interpreting you incorrectly.


Not unless each block is only 1x1 pixels. If each block is, say 20x20 pixels you might have a 40x30 grid of numbers representing blocks, or you might have a set grid of say 20x20 bricks that are scaled to whatever res you need them at.
Those who dance are considered insane by those who cannot hear the music.
pdstatha
pdstatha
So....


110000000011
011000000110
001100001100
000110011000
000011110000
000001100000
000110110000
001100011000
011000001100
110000000110


A bit like this then????

Should it be a 2d array??

Or should I use a vector instead??
disgracelands
disgracelands
You can have Overloading, Overriding and function hiding. Both overloading and function hiding are decided at compile time but overriding (using virtuals) is decided at run time.


If we have a base class A and 2 derived classes X and Z

A a;
X x;
Z z;
A* pointer;
pointer = &x
pointer->foo(); //X''s version of foo is called
pointer = &y
pointer->foo(); //Y''s version is called
pointer = &A
pointer->foo(); //A''s version is called

This might not seem very usefull (and generally it''s not) but it is when unknowns are involved. If we are recieveing user input and we have 2 methods of proceeding we can take a pointer of class A and make it a pointer to X or Z depending upon the user. Either way we still call foo.

Very, very handy. At least it is once you get your head round the concept.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.