How to copy a (clipped) sprite on an image ?

Just starting out? Need help? Post your questions and find answers here.
pythagoras_156
User
User
Posts: 13
Joined: Wed Aug 20, 2003 11:08 am

How to copy a (clipped) sprite on an image ?

Post by pythagoras_156 »

Hello everyone,

My problem is the following :
I've got a sprite loaded. Basically, it's a tileset which i need to clip from to display a specific tile.
My problem is that i need to put that clipped part of the sprite tileset into an image (i'm working on a map editor and i can't display sprites in my listicon gadget).
So, the difficult part is to display the sprite on the image. I've tried a bit with bitblt_ function but i don't understand it fully, so i might be making a mistake somewhere.
Does anyone has an idea on how to copy a (clipped) sprite onto an image ?

Thanks in advance,

Pythagoras
plouf
Enthusiast
Enthusiast
Posts: 281
Joined: Fri Apr 25, 2003 6:35 pm
Location: Athens,Greece

Post by plouf »

can't think a way to do that
but what you ask can be done diffrently with image commands :wink:
a) load the big image in a temporary image
b) grabimage ,grabimage grabs a square from another image and creates a new one :wink:

later if you wish to make sprites too you can use 2DDrawing command to
drawimage() in sprite -> startdrawing(spriteoutput())
:wink:

OOT are you greek ?
Christos
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post by LarsG »

of course it can be done.. ;)
just load your tile image into a sprite, set drawing to another
image or sprite, and use this procedure to display the different tiles..
:wink:

Code: Select all

Procedure DrawClippedSprite(image, x, y, sizex, sizey, frame)
    Protected initwidth.l, initheight.l, yc.l
    initwidth = SpriteWidth(image)
    initheight = SpriteHeight(image)
    yc = Int(Round((frame * sizex) / initwidth,0))
    frame = frame - (yc * Int((initwidth / sizex)))
    yc = (yc * sizey)
    ; get the right part of the image
    ClipSprite(image,sizex * frame, yc, sizex, sizey)
    DisplayTransparentSprite(image,x,y)
    ; reset the clipsprite back to the initial values (size)
    ClipSprite(image,0,0,initwidth,initheight)
EndProcedure

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
pythagoras_156
User
User
Posts: 13
Joined: Wed Aug 20, 2003 11:08 am

Post by pythagoras_156 »

Thanks for your replies. I'll try the grabimage tip, looks like the best way to achieve it.

LarsG :
Your function is great and will turn out useful but what i was looking for was basically to copy a sprite onto an image. As far as I know, it's not possible to make a call for displaysprite and have it displayed onto an image (startdrawing(imageoutput()) ?)

plouf :
Nai, vre :D . Ypothetw k'esy ; Apo Athina ;
plouf
Enthusiast
Enthusiast
Posts: 281
Joined: Fri Apr 25, 2003 6:35 pm
Location: Athens,Greece

Post by plouf »

i don;t understand how do you "draw" a sprite in an imageoutpu() ??

pythagoras take a visit in irc channel at night 10:00-11:00 greek time ;)
Christos
Post Reply