Log In  

In my game, bullets have in different sizes. I want to use a sprite for the bullet but don't want to make a sprite for each possible size because it will vary (or be random).

I'm hoping there is a way to scale/enlarge/shrink a sprite so I can just make one sprite and use it lots of places.

P#20915 2016-05-20 11:07 ( Edited 2016-05-20 17:14)

That would be the sspr function, you can use it to select a portion of your sprite map and then stretch it to any size you'd like.

sspr(sx, sy, sw, sh, dx, dy, [dw, dh, [flip_x, [flip_y]]])

Stretch rectangle from sprite sheet (sx, sy, sw, sh) // given in pixels
and draw in rectangle (dx, dy, dw, dh)
Colour 0 drawn as transparent by default (see palt())
dw, dh defaults to sw, sh
flip_x=true to flip horizontally
flip_y=true to flip vertically

P#20916 2016-05-20 11:09 ( Edited 2016-05-20 15:11)

Gotcha, thanks. I found that manual description kind of confusing, just me I guess.

P#20918 2016-05-20 11:46 ( Edited 2016-05-20 15:46)

Nah, you are not the only one. I find the manual confusing at times.
...and now to piggy back on this topic:

Is there a way to rotate a sprite 90 degrees?

P#20919 2016-05-20 12:04 ( Edited 2016-05-20 16:04)

Currently as it seems, no, only H ou V flips.

P#20920 2016-05-20 12:07 ( Edited 2016-05-20 16:07)

Shame, hopefully it will show up in the future.

It could help making simple animation (ball spinning) using only a single sprite.

P#20921 2016-05-20 12:23 ( Edited 2016-05-20 16:23)

On some sprites, H/V flip could do the job

P#20923 2016-05-20 12:38 ( Edited 2016-05-20 16:38)

I've been using and abusing the flip flags all over in my games. Combining that with pal() and I've managed to reduce my sprite sheet down to only a handful rather than dozens. That pal() method is a gem...saves a lot of sprite drawing work too.

For a spinning ball, you could do it with 2 sprites, I think. One sprite with the ball up, then one with the ball at 25* tilt...then just flip as you go around in your loop. The more sprites you have the more fluid but even then you could do it with only a few sprites.

P#20926 2016-05-20 13:03 ( Edited 2016-05-20 17:03)

morningtest: this is (was) a common practice when you have a palette you can change. It was common use on the NES for example to have a tile that will look differently depending on the palette applied, or do some basic animation for sprites.

One great "abuse" of palette was the work from Mark Ferrari on most of the Lucas Art Scumm game: http://www.effectgames.com/demos/canvascycle/

P#20928 2016-05-20 13:14 ( Edited 2016-05-20 17:14)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 14:06:40 | 0.008s | Q:20