C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 24th, 2003, 12:07 PM
infamous41md's Avatar
infamous41md infamous41md is offline
not a fan of fascism (n00b)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Feb 2003
Location: ct
Posts: 2,756 infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 11 h 4 m 29 sec
Reputation Power: 94
question about graphix programming

ok, does everyone remember that game Arkanoid in the arcades from a loooooooong time ago? it was teh one where u have a small paddle on the bottom of the screen and the objective is to bounce the ball against the blocks on the top of the screen to knock them all off? My question is, when u have the ball bouncing off the walls and paddle and blocks, how do u calculate the angle that it bounces back? Im assuming there must be some algorithms that already exist b/c i cant even fathom how to write one!! Anyone know or have an y useful links? i already googled and came up with no results.

Reply With Quote
  #2  
Old March 24th, 2003, 01:17 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,966 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 52 m 24 sec
Reputation Power: 189
Arkanoid - Breakout ... good old times

Without further influence, AFAIK things bounce off this way:

angle out = 180° - angle in
__________________
--
Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more.

Reply With Quote
  #3  
Old March 24th, 2003, 01:32 PM
infamous41md's Avatar
infamous41md infamous41md is offline
not a fan of fascism (n00b)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Feb 2003
Location: ct
Posts: 2,756 infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 11 h 4 m 29 sec
Reputation Power: 94
ahhh, now i remember that from the good ol Algebra II days... how may i ask does one find the trajectory/entry angle of the ball? is there a class in MFC or something that contains methods like this? all my searches on google result in greedy bastards wanting $$$ for this info . and Arkanoid was one of the best games ever!! i've been looking for an old arcade machine to buy but they are so ridicuosly xpensive on eBay.

Reply With Quote
  #4  
Old March 24th, 2003, 01:49 PM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,142 dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 15th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 4 Days 33 m 48 sec
Reputation Power: 1974
Quote:
Originally posted by infamous41md
ahhh, now i remember that from the good ol Algebra II days... how may i ask does one find the trajectory/entry angle of the ball? is there a class in MFC or something that contains methods like this? all my searches on google result in greedy bastards wanting $$$ for this info . and Arkanoid was one of the best games ever!! i've been looking for an old arcade machine to buy but they are so ridicuosly xpensive on eBay.


Sounds like what I knew as "Breakout". That might help widen your search.

As for the entry angle, couldn't you just define an acceptable range of angle values and then pick one randomly?

Reply With Quote
  #5  
Old March 24th, 2003, 01:51 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,966 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 52 m 24 sec
Reputation Power: 189
Someone wants $$ for that info? You can read it in any algebra or physics book!

In general, you remember:
sin(alpha)=b/c
cos(alpha)=a/c
and tan(alpha)=b/a
in a triangle with (my words, too lazy to look up a translation service ) close side a, far side b and hypothenuse c.

but depending on the way you are storing your ballŽs current state, it can be more complicated to calculate that.

How does the code for that look like right now? (how do you store angle / position / velocity of your ball?)

Reply With Quote
  #6  
Old March 24th, 2003, 02:00 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is online now
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,390 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 22 h 36 m 15 sec
Reputation Power: 4080
Heck, I always used code like this:
Code:
int dx = 5, dy=5;
while (playing) {
   x += dx;
   y += dy;

   if (x < 10 || x > max_width-10)
      dx = -dx;

   if (y < 10 || x > max_height-10)
      dy = -dy;
}


Simple and efficient. If it hits an edge, bat, brick etc., simply reverse the value of dx or dy.

Reply With Quote
  #7  
Old March 24th, 2003, 02:00 PM
infamous41md's Avatar
infamous41md infamous41md is offline
not a fan of fascism (n00b)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Feb 2003
Location: ct
Posts: 2,756 infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 11 h 4 m 29 sec
Reputation Power: 94
"but depending on the way you are storing your ballŽs current state, it can be more complicated to calculate that.

How does the code for that look like right now? (how do you store angle / position / velocity of your ball?) "


-well, this is kind of what i was asking.i havent yet started coding anything. i wanted to have a firm grasp on how i would go about this b4 i got myself into something i couldnt complete. i just made my first game ever in C++, and that was a tic tac toe game, so, anything that involves motion is a HUGE step for me. not sure if it's a step i can even take, that's why i was curious how one would go about setting up something like this. i was hoping someone had a good link to a site for beginners tutorials on game programming in C++. all the searches i do just turn up crap or want a "subscription fee", but i guess i'll go back and try to change up my search terms and maybe i'll stumble across something good....i'm sure it's out there somewhere

Reply With Quote
  #8  
Old March 24th, 2003, 02:09 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,966 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 52 m 24 sec
Reputation Power: 189
Scorpions4Ever gave you the answer if you used dx and dy in independent variables (probably best choice for 2D gaming - dx and dy being the movement speed for x and y in pixels per tick - "delta X and delta Y"). For a simple "180-angle in" calculation, this does the trick. If you want to add "spin" to your ball, youŽll need some more calculation though...

HereŽs a cool site for games programming that youŽll have to read for months to get all their cool ideas and tricks (I didnŽt get thru half of them yet although I know it for over one year already - but my free time is rare... ):

www.gamedev.net

Reply With Quote
  #9  
Old March 26th, 2003, 10:50 AM
Jason Doucette's Avatar
Jason Doucette Jason Doucette is offline
jasondoucette.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Canada
Posts: 378 Jason Doucette User rank is Private First Class (20 - 50 Reputation Level)Jason Doucette User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 7 h 23 m 8 sec
Reputation Power: 11
I made an arkanoid clone for 360x360 mode X, but never finished it as a game. The one thing that I did proper was proper collision detection, which none of any of the breakout/arkanoid clones (or originals) did properly. Every version of this game only sees the ball hitting bricks at either a flat surface, or a 45 degree angle for the corners. If this is all you are looking for, then the explanations in this thread are fine. If you wish to do it properly, then you have to start thinking about how physics work with real life objects. The calculations are pretty difficult, and cannot be answered in a simple post.

I wish to someday release my version as a commercial product at some point in the future, but have no time for it now. My demo is here: Arkanoid '97 please note: it runs in 360x360 mode-x, so don't blame me if your monitor is not 100% VGA compatible and cannot handle the mode

Reply With Quote
  #10  
Old March 26th, 2003, 04:29 PM
infamous41md's Avatar
infamous41md infamous41md is offline
not a fan of fascism (n00b)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Feb 2003
Location: ct
Posts: 2,756 infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 11 h 4 m 29 sec
Reputation Power: 94
M.Hirsch << damn that website is awesome... so much stuff on there and so many cool links. i found this one site that had tons and tons of video games with indepth articles about the AI and graphix in them. thnx

jason<< i wasnt able to run that program, but i did read about that and a bunch of other stuff on ur site. good stuff!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > question about graphix programming

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap