Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 14th, 2006, 1:31 AM   #1
josec
Newbie
 
Join Date: Nov 2006
Posts: 4
Rep Power: 0 josec is an unknown quantity at this point
Exclamation help w/ bouncing ball and bitmaps code

Hi i need urgent help. I have to do a program of an animation of a ball bouncing against the wall and predetermined obstacles. My professor told me that i can write a program where the user can input the ball's speed from slow, medium or fast, choose which obstacles the user wants from predetermined ones and for how long the animation should go. then the program should create a series of images. then i will take these images and use a movie maker program to create the program. She told me to use a bitmap to acomplish this. however, I have no idea how to use a bitmap or how to start doing this program. can someone help out, and show me at least how to start just guide me and i'll figure out the rest. bu the way we are using unix to compile the program. and then the pics will be exported to windows to create the animation. thank you very much!!!
josec is offline   Reply With Quote
Old Nov 14th, 2006, 1:37 AM   #2
Game_Ender
Professional Programmer
 
Game_Ender's Avatar
 
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3 Game_Ender is on a distinguished road
First you need to create some buffer that represents your screen and then some functions to draw what you want on that buffer. Then you make all your calculations and draw on buffer. After that write your buffer to file in the .bmp format. Repeat the calculate - draw - write-bmp sequence as needed.

See some information on bmp format here.
Game_Ender is offline   Reply With Quote
Old Nov 14th, 2006, 1:42 AM   #3
josec
Newbie
 
Join Date: Nov 2006
Posts: 4
Rep Power: 0 josec is an unknown quantity at this point
i'm sorry but what is a buffer and how do i create one? i forgot to mentioned that i am new in C, and even though i like C, my knowledge about it is very limited
josec is offline   Reply With Quote
Old Nov 14th, 2006, 2:25 AM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
While someone is amassing a lesson plan for you, please read the forum's rules/FAQ. Note in particular that cross-posting is not allowed.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 14th, 2006, 3:54 AM   #5
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
A buffer is simply a temporary location in which to store data. In this case, the buffer can hold a single bitmapped frame of the bouncing ball animation. However, I honestly think you need to go over your professor's lectures, or ask for some help. It seems a tricky piece of programming for someone who's inexperienced.
Arevos is offline   Reply With Quote
Old Nov 14th, 2006, 1:47 PM   #6
sixstringartist
Programmer
 
Join Date: Jun 2005
Posts: 68
Rep Power: 4 sixstringartist is on a distinguished road
From your response, you seems to be very new at C, in which this problem would be very difficult for you. Have you been attending/paying attension in class? Not trying to dog you, it just seems like you should have more tools at your disposal to solve this problem.
sixstringartist is offline   Reply With Quote
Old Nov 14th, 2006, 2:02 PM   #7
josec
Newbie
 
Join Date: Nov 2006
Posts: 4
Rep Power: 0 josec is an unknown quantity at this point
yeah i've payed attention in class and right now we just finished pointers. however, this porject is my final project and the professor wants us to do something that would challenge ourselves. so that's why i've been researching and looking around to ways to write this program.
josec is offline   Reply With Quote
Old Nov 14th, 2006, 3:12 PM   #8
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
Ok, use the buffer as told by other members to store your bitmap temporarily, and learn the structure of an image format like .bmp.

For the bouncing of the ball itself, recall your physics lessons you probably have had at school.
Polyphemus_ is offline   Reply With Quote
Old Nov 14th, 2006, 3:22 PM   #9
MBirchmeier
Hobbyist Programmer
 
Join Date: Oct 2005
Posts: 211
Rep Power: 4 MBirchmeier is on a distinguished road
Keep in mind a bitmap is a static image. Perhaps you're looking to create a bitmap, or perhaps you're looking to create an animation. If you're looking to animate you'd need a graphics library (e.g. openGL etc.) if you're just looking to take a snapshot of a scenario you could create a bitmap.

-MBirchmeier
MBirchmeier is offline   Reply With Quote
Old Nov 14th, 2006, 3:50 PM   #10
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by MBirchmeier View Post
Keep in mind a bitmap is a static image. Perhaps you're looking to create a bitmap, or perhaps you're looking to create an animation.
It sounds like the task is to create a series of still frames that can then be compiled into an animation separately.
Quote:
Originally Posted by josec
yeah i've payed attention in class and right now we just finished pointers. however, this porject is my final project and the professor wants us to do something that would challenge ourselves. so that's why i've been researching and looking around to ways to write this program.
I'd start off simple, and build up. For instance, you could do this:

1. Create a program that reads in a text file and changes every other letter to an x. For instance, if you have a text file with "Hello World", your program would create a text file with "HxlxoxWxrxd".

2. Create a program that creates a series of text files in which an X moves horizontally across the page. e.g.
1.txt:
....
x...
....

2.txt:
....
.x..
....

3.txt:
....
..x.
....

4.txt:
....
...x
....

3. Expand the program in step 2 so that the ball moves diagonally around, bouncing off the edges when it reaches them.

4. Create a program that reads in a bitmap, and creates a new bitmap from it where every other pixel is set to black.

5. Create a program that reads in a bitmap, and displays a new bitmap from it with a black square in the middle.

6. Create a program that reads in a large bitmap and a small bitmap, and produces combination bitmap with the small bitmap in the centre of the large bitmap.

7. Expand exercise 6 to produce a series of bitmaps, where the smaller bitmap inches its way across the larger bitmap.

8. Create your final bouncing ball program.

Hope that helps!
Arevos is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:58 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC