|
This thread is locked; no one can reply to it. |
1
2
|
What is this exactly? (BITMAP related) |
julian_boolean
Member #8,201
January 2007
|
The basic what? |
Rampage
Member #3,035
December 2002
|
I said: arithmetic operators Like +, -, *, / and %. -R |
BAF
Member #2,981
December 2002
|
+ is addition. It adds two numbers together. If I have 3 posts and I add 2 posts to it, how many posts do I have?
/ is division. If 430 posts are posted by 10 users, what was the average per user? |
GullRaDriel
Member #3,861
September 2003
|
God, BAF, you are too good. Julian_Boolean: Are you sure you ever learn C or C++ ? Last time I was cool, but I should not have been that sweet. I told you something helpful. I told you to learn, and learning is always helpful. Now excuse me, but not knowing how to do a division while it is really basic programming... I could not have been more cool with you than telling you should go back to learn. "Code is like shit - it only smells if it is not yours" |
julian_boolean
Member #8,201
January 2007
|
BAF: Thank you very much I already know/heard of the first three. I know division, I just thought / might mean something else. % on the other hand, I had no clue what that meant. GullRaDriel: orly? |
GullRaDriel
Member #3,861
September 2003
|
Oh, really, yes ? I could have told you to RTFM, to stop programming, ... Else I told you to go back learn. So, oh, really, yes. Just launch calc in Windows, and see, the division button, it is a '/' . Astonishing , isn't it ? EDITED "Code is like shit - it only smells if it is not yours" |
Paul Rowan
Member #8,612
May 2007
|
Hi Julian, This bit of code is to help you grab individual sprite frames from a sprite sheet. It's actually in a book called 'Game Programming All In One 2nd Edition by Jonathan S. Harbour' which concentrates on developing games using 'C' and Allegro. An example is of a sprite sheet containing 32 images of a rotating ball, 8 columns wide by 4 rows deep. Each sprite image is 64x64 pixels. What you need to do to make it work is to include this code (say in main()) for ease of showing it is as follows: BITAMP *temp; //load 32-frame tiled sprite image Before main() you need to include: BITMAP *ballimg[32]; a quick re-cap of the grabframe function arguments: temp = spritesheet (in this case sphere.bmp) You can have more then 1 set of sprites in a sheet and thats why you can alter the sizes of the width/height of the frames and where in the sprite sheet x,y to start grabbing them from. Hope this helps, but if you need a demo i'll supply a complete code listing and graphics for you to play with |
julian_boolean
Member #8,201
January 2007
|
Yes! Thank you very much! What I wanted to know was how could I do that in C++? (Please don't laugh at me ) // eh? BITMAP* myclass::grabframe(...) { ... } Edit: Would it make it easier to take rows into consideration and use it as a parameter? |
Paul Rowan
Member #8,612
May 2007
|
Sorry, I am only just learning myself how to use Allegro to create games, and I'm using the book mentioned in my previous post which uses C only, and I'm having to learn that too . I have no experience yet of using C++, so I can't help you with your problem |
BAF
Member #2,981
December 2002
|
Uhm... what's not C++ about the original? I don't see many changes you can make to it, unless you put it in a class and make a whole animation system. |
julian_boolean
Member #8,201
January 2007
|
NM! I guess I was just doing something wrong, it compiles now.. But crashes.. BUT I get no errors! So I'm on the right track. |
Paul Rowan
Member #8,612
May 2007
|
If it's compiling OK then ur code is fine. One reason it may be crashing, cos this has happened to me before, is to make sure that the graphics file is being loaded properly into temp - put an error checker on it to see if this loads in correctly first. |
julian_boolean
Member #8,201
January 2007
|
My brother actually has that book, well the third edition. I found a different function inside of it that seems to work better (it doesn't crash and even displays the first frame in the sheet!) But I can't move it around with my arrow keys. Here's the function: void drawframe(BITMAP* source, BITMAP* dest, int x, int y, int width, int height, int startx, int starty, int columns, int frame) { int framex = startx + (frame % columns) * width; int framey = starty + (frame / columns) * height; masked_blit(source, dest, framex, framey, width, height); } I fooled around with it and it seems like it should work. drawframe(image, buffer, x_being, y_being, 80, 80, 0, 0, 8, curframe); If I replace curframe with just a number, the correct frame will pop up when I compile it, but I still can't move it.. I think I might know what's wrong but I'm VERY happy this function works. Edit: Okay something is really screwed up:
It's still showing frame 0 on my sprite sheet for some reason. |
GullRaDriel
Member #3,861
September 2003
|
Hum... There is NOTHING magic in programming. If you need it to step one frame, you must tell it to do so. The line drawframe(image, buffer, x_being, y_being, 80, 80, 0, 0, 8, curframe); will always draw the same frame until you make some change. I see a curframe = 10, I do not see a curframe ++ or something else. I think that you should really spend some times understanding how this (simple) function works. "Code is like shit - it only smells if it is not yours" |
julian_boolean
Member #8,201
January 2007
|
Quote: I do not see a curframe ++ or something else. Your point? I already found the problem and it a simple mistake (had nothing to do with the function.) After fixing it setting curframe to 10 works, obviously. |
LennyLen
Member #5,313
December 2004
|
Quote: After fixing it setting curframe to 10 works, obviously. If you've fixed the problem yourself, you should make an addendum to your post, so that others don't keep trying to solve the problem for you. Also, why does your function take x and y parameters if they're not being used?
|
GullRaDriel
Member #3,861
September 2003
|
julian_boolean said:
It's still showing frame 0 on my sprite sheet for some reason.
First: You never wrote that your problem was solved. Ending: EDIT: beaten a few by LennyLen "Code is like shit - it only smells if it is not yours" |
julian_boolean
Member #8,201
January 2007
|
They are being used, just not in the code I showed. I set curframe to 10 so I could test to see if the proper frame would show up on the screen, using the x and y coordinates given somewhere else in the program. |
|
1
2
|