How to detect a TILE size?

Previous topic - Next topic

spacefractal

I want to get the size of the tile of a anim, but have a problem.

If I use GETSPRITESIZE i got the whole image size, rather than tile size as I want.

So GETSPRITESIZE object, w, h is not a option at all when using anim.

This is due STRETCHANIM command want to known its size, rather than using procent like other commands does. That is really dumb, when the app dont known the size of it and then it would been fussy.

Also STRETCHANIM use current size rather than using procents, like other commands do.

I trying to just mirror a animated sprite (in one axis), using its current tile size.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrTAToad

If you use LOADANIM you can use the values you give that.

If you use LOADSPRITE and then want to use SETSPRITEANIM, as long as you know how many tiles are across and down, you can then work out the tile size.

spacefractal

the issue is the what I coded the "paint()" part is, the woudl been much easier if its could return the tile info with such of command. Look like I need create a little list with object sizes instead.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrTAToad

Sounds like the way to do it.

XanthorXIII

How about GETSPRITE with a combination of calculations of what the size of each tile should be?
Owlcat has wise

erico

can´t you also have a red dot on the lower right corner of each sprite? and them check for this dot color to find out the size?
although if you resize it all I guess it won´t work...

...XanthorXIII´s plan sounds better.

MrTAToad

You could scan horizontally and vertically looking for a colour, and then continue from that and grab a rectangular area based on the coordinates given - the Amiga version of BlitzBasic would do that to grab sprites

XanthorXIII

spacefractal - You're using Sprite Sheets correct?
Owlcat has wise

Slydog

Quote from: XanthorXIII on 2011-May-16
spacefractal - You're using Sprite Sheets correct?

That's what I was wondering.
If so, and you used the 'LOADANIM()' command, you already know the tile size, as that's a parameter to the command.
Unless you've loaded multiple sprite sheets using this command and you no longer have access to the tile size info for a specific sprite.

If this is the case then I would recommend creating a 'SPRITE' type (or 'ANIMATION' type).
This would store your spite and animation info, such as tile size.

Code (glbasic) Select
TYPE TAnimation
  sprite_id%
  tile_size_w%
  tile_size_h%

  FUNCTION Load: fileName$, tile_size_w%, tile_size_h%
    self.sprite_id = SpriteIdNew()
    self.tile_size_w = tile_size_w
    self.tile_size_h = tile_size_h
    LOADANIM fileName$, self.sprite_id, tile_size_w, tile_size_h
  ENDFUNCTION

  FUNCTION Draw: frame%, x%, y%
    DRAWANIM self.sprite_id, frame, x, y
  ENDFUNCTION
ENDTYPE

FUNCTION SpriteIdNew%:
  STATIC sprite_id% = 1000
  INC sprite_id
  RETURN sprite_id
ENDFUNCTION

//Usage:
LOCAL anim AS TAnimation
anim.Load("sprite_sheet.png", 32, 32)
anim.Draw(1, 100, 100)
width = anim.tile_size_w


This is just for example, this code may not work, just made it up.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

spacefractal

Yes its somewhere extractly that I did (Slydos code), because I use varied in sizes animation, and the code very separate the update() and paint() completly. So I need just to add 2 new variables to the struct. But would been lots easier to just detect it when paint a image (via a function of course, not directly), due that way I have coded it.

I do still wonder, but this is more a request, so hence not a bug or something like that.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/