SUPER BMP24() function! (rotation and scaling! v.1)

Post here your demos and examples with the source files.
Forum rules
Always post the games with a screenshot.
The file must have the ged and data files (complete game source)
Use the forum attachment to post the files.
It is always better to use the first post to put the game files

SUPER BMP24() function! (rotation and scaling! v.1)

Postby pyrometal » Sat Jun 14, 2008 3:18 pm

Hello everyone! My previous bmp24 function series have been completly revamped into a much more intersting super function with full rotation/scaling capabilities! It's still far from perfect, and I will state its limitations later. I decided to do this after helping game-a-gogo with his current project for which he needed rotation codes. Had an extreme programming night yesterday to make this happen.

screenshot.PNG
testing in progress

bmp24 function demo.zip
Free to use, give credit if used though... plz
(4.64 KiB) Downloaded 169 times


LIMITATIONS:
- Limited to a set size (320*240pixels), it can be increased though.
- 24bit uncompressed bmp files only.
- Works best with small square sized images, large differences in width/height MAY screw up, in some cases, pretty badly...
- Larger files suffer from inacuracies around edges, especially corners.
- Some scales may look shitty.
- Not suited for extensive real time applications.

I will strive to improve this function as much as humanly possible in the future, may take a bit though... I decided to release it because it is usable and can give decent results depending on what it is given to process. Please do comment! It will help me improve the function much more!

--pyro (cuz I'm insane)
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 694
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 85 Give a positive score

Re: SUPER BMP24() function! (rotation and scaling! v.1)

Postby Game A Gogo » Sat Jun 14, 2008 3:59 pm

here is a good example of what he means by real time applications.

though this can be very appealing, it lags too much when it comes too big.
Attachments
BMP_thing.zip
Example
(6.4 KiB) Downloaded 115 times
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3464
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: SUPER BMP24() function! (rotation and scaling! v.1)

Postby Game A Gogo » Sat Jun 14, 2008 4:04 pm

Also an idea would be to skip certain process, like maybe skip the scaling process when it's set to one. and for the rotation skip it when it's 0 or any multiple of 360.

anyways. this is pretty amazing work :3

You also forgotten to state one limitation. your pictures needs to be a multiple of 4 in width or else, it will be tilted. this is due because any BMP program when saving will place empty data to make each line a multiple of 4. like this:
Code: Select all
FF FF 6F | 99 FF 99 | 00 FF FF | 00 00 00


if you can get what I mean...

it could be possible to alter this by checking the width with %

maybe this might work:
Code: Select all
(width%4)*3
could maybve tell how much bytes at the end of each lines to skip

EDIT: I can't remember if it was multiple of 4 or 3...
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3464
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: SUPER BMP24() function! (rotation and scaling! v.1)

Postby pyrometal » Sat Jun 14, 2008 4:30 pm

Your right gogo, I didn't realize that this was the problem, I will add this stuff in a little later! Thanks!
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 694
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 85 Give a positive score

Re: SUPER BMP24() function! (rotation and scaling! v.1)

Postby Game A Gogo » Sat Jun 14, 2008 6:54 pm

no problem, glad I was able to help ya back :D
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3464
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: SUPER BMP24() function! (rotation and scaling! v.1)

Postby feral » Sun Jun 15, 2008 12:01 am

very nice pyro, :D

just a suggestion, but what i would like to see ( you probably have thought of this anyway)

but I would like to see an application written using this, and or game-a-gogo's tool that outputs sprite sheets of prescaled/rotated sprites so that you could then reload the prerendered ones back in as normal sprites.

either as a single page of pre-gridded sprites or as a set of numbered files eg: bitmap01.bmp, bitmap02.bmp, etc etc

the cool part about that, is you could ship your games with the single "core" sprites ( very small download package ), then on install ( or first time game is played) the game itself generates all required sprite sheets eg: game-a-gogos spaceship game would only need to be packaged with the original spaceship.bmp, but on install... generates a spritesheet of all rotations to be loaded back in

pseudo code
if (not exist spaceship01.bmp)
{
generate(36)
}
//if sprites don't exist (therefore must be the first time played) generate 36 ( or whatever) rotations and save as bitmaps

then just before zipping the game for distribution the programmer deletes all unneeded sprite sheets from game, and they all get recreated on install - make sense ?

but, just being able to create spritesheets themselves would be cool

just trying to make your life harder then it already is... :lol:

good work tho.

feral
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: SUPER BMP24() function! (rotation and scaling! v.1)

Postby DST » Sun Jun 15, 2008 12:16 am

That's a pretty cool idea....its like MIDI only for images....Ur pretty good at this savag....i mean Feral. :P
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 150 Give a positive score

Re: SUPER BMP24() function! (rotation and scaling! v.1)

Postby pyrometal » Sun Jun 15, 2008 12:59 am

Thanks for the idea feral! I will consider building this, but I will have to delay that until my 6 week course is over, I'm leaving tommorow... Tonight, I will fix the problem Gogo mentioned and possibly optimize other bits of it.
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 694
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 85 Give a positive score

Re: SUPER BMP24() function! (rotation and scaling! v.1)

Postby Game A Gogo » Sun Jun 15, 2008 2:35 am

you have given me an idea...

make a program that generates rotations files :D

but I guess I would work on that later lol
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3464
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: SUPER BMP24() function! (rotation and scaling! v.1)

Postby DST » Sat Jul 05, 2008 11:40 am

That bmpthing(realtime) is pretty cool. Its based off traditional c code way of doing things isn't it? A pixel array or something like that?
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 150 Give a positive score

Re: SUPER BMP24() function! (rotation and scaling! v.1)

Postby Kooldudese » Thu Jul 10, 2008 5:15 pm

i was testing out this function and, i have to admit this is very nice, and useful, exept there was one thing i tried that didnt work, i was wondering if this is possible, mabye i just typed the code incorrectly or if this doesnt work with this specific function. and i was wondering if it doesnt work with the function if you could mabye figure out how to make it work with it... it would be very useful for me (and nodoubt for others aswell) ok, heres the point:
i tested the BMP24() function and this is what i was trying to do:
i was trying to make it so that the angle would be a variable, so for example:
//Script
bmp24("test.bmp",20,14, 1,0,Angle"x");
the Angle variable was set to relative the canvas and the enemy (which can move, aswell as the canvas)
//Script
Angle = direction(bmp24_canvas.x, bmp24_canvas.y, Enemy1.x, Enemy1.y);

what happend was... it worked, but what happend was the original angled .bmp was still there and they overlaped, basically it loaded the picture twice at different angles. im guessin that i just have to figure out how to delete it before it loads the second picture, but i havent been able to figure this out yet. and plus it wont work the way i did it because i set it to Draw actor instead of Create actor. and im not sure if it will work with Create actor, because you will have to set a create actor when you want the relative angle to be calculated. plz if anyone can help me with this i would be greately appreciated. :wink: thanks in advance!
User avatar
Kooldudese
 
Posts: 128
Joined: Sat Jan 27, 2007 5:20 pm
Location: In a house
Score: 0 Give a positive score

Re: SUPER BMP24() function! (rotation and scaling! v.1)

Postby feral » Fri Jul 11, 2008 12:44 am

I think this is what you want..
b24demo.zip
ged files and sample bitmap
(16.73 KiB) Downloaded 92 times

to make life easier,.. I rotated the original bitmap file so that the "top" of the bitmap is the "top of the pointer.. or 'top' of spaceship/enemy etc etc

open up the bitmap file to see what i mean.

this demo uses the bitmap24() function to make an enemy turn in your direction.

use cursor keys to move actor

note: when using direction() you need to find the "center" of the canvas using height/width

ang=direction(enemy.x,enemy.y,x+width/2,y+height/2);

if this is not what you wanted, let me know

feral
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: SUPER BMP24() function! (rotation and scaling! v.1)

Postby Kooldudese » Fri Jul 11, 2008 12:21 pm

Thank you, ever so much =P +1 point
(I love this forum people are so great =)
:lol:
User avatar
Kooldudese
 
Posts: 128
Joined: Sat Jan 27, 2007 5:20 pm
Location: In a house
Score: 0 Give a positive score

Re: SUPER BMP24() function! (rotation and scaling! v.1)

Postby Kooldudese » Fri Jul 11, 2008 1:25 pm

I have one last question, what im trying to do, is make the arrow (the actor that rotates) move to the enemy at the angle, but when i try it with "move to" it always moves to one exact location on the enemy, so if it was on the opposite side it would flip over to the spot... plz help me again, oh and thx again for earlier=)
User avatar
Kooldudese
 
Posts: 128
Joined: Sat Jan 27, 2007 5:20 pm
Location: In a house
Score: 0 Give a positive score

Re: SUPER BMP24() function! (rotation and scaling! v.1)

Postby feral » Fri Jul 11, 2008 10:00 pm

Kooldudese wrote:I have one last question, what im trying to do, is make the arrow (the actor that rotates) move to the enemy at the angle, but when i try it with "move to" it always moves to one exact location on the enemy, so if it was on the opposite side it would flip over to the spot... plz help me again, oh and thx again for earlier=)


ok .. this one comes in two parts

1. making the "arrow" go to the center of the player and not the same spot on the side..
Moveto uses the upper left corner as the coordinates. in otherwords the 0,0 of the sprite being moved is the upperleft corner

so the upperleft corner of the sprite is what will "touch" the center of the object being moved too. in this case because the canvas is partly empty, it makes it appear that the arrow is moving off to the side at same point each time.. when in fact the upperleft coner of the canvas is actually centered on the object being moved to.

to counteract this, in the move to, you need to "offset" the moving object (the canvas in this case) by half its width and height. you do this by by subtracting it from the x,y of the moveto command

an example:
MoveTo("player_canvas",-player_canvas.width/2,-player_canvas.height/2, 10.000000, "enemy", "");

2. you need to stop the "arrow" from turning once it hits the character because once it "centers", the angles all change.

to do this, I will only change the angle, 'if' the canvas if it is not touching the player... that way it stays at its last position after colliding

I used a global variable 'on_enemy' and set it to 1 on collision

then on the bitmap draw command set it so once 'on_enemy' is = 1, it no longer recalculates the angle..

if (on_enemy!=1) //global variable set to 1 if collide
{
ang=direction(enemy.x,enemy.y,x+width/2,y+height/2); //only recalc if 'on_enemy' is =0
}

I could have also stopped redrawing the arrow at this point , and just continued to move the canvas, but, because it is very slow to draw the arrows, when I stop drawing them everything suddenly speeds up.

see example code attached... use mouse button ( click on the arrow) to activate... I removed the cursor controls while making this so smiley no longer moves..
bmpseek.zip
ged and sample bitmap
(17.89 KiB) Downloaded 94 times

NOTE: unless you have a very specific reason for using canvas drawing, you may want to consider other options, because canvas drawing can get very slow..

hope that helps
feral
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Next

Return to Game Demos

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest