Still waiting for...

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Madman.

some command to copy a rectangle part of some image into the video buffer or some other image. This function would be very handy for tilebased levels, like many many RPG style games use this kind of levelengine.
Its doubtlessly faster to quickly copy the displayable map together from a tileset-gfx and scroll the finished imagefile than handle 500+ sprites as proposed in my earlier thread (that seems to have vanished by now)

PB doubtlessly is by far the best Basic, but a missing command like this should be implemented asap imho. All other Basic dialects have compareable commands.

Please consider adding such function. TY ! :)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

Why not use the ClipSprite() command, and then DisplaySprite()
Does the job quite well for me.

Timo

http://freak.coolfreepages.com/
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Madman.

So you load the entire tileset into memory for each tile you must display, shrink the viewport and display that ?
Lets calculate a bit:

Considered 800x600 screenresolution, and a tilesize of 16x16 pix,
we need 50 tiles for x and approx 38 for y axis just to fill the screen (no scrolling here yet)
50x38 = 1900. Hmm. You flush around 1900 sprites to achieve something, that can be done with a single gfx ?
Now lets make the level a bit bigger. Lets say we make the level 1600x1200 pix.
Unless we use bigger tiles (32x32) you have 3800 sprites to handle.

Now if PB loads the entire gfx and only displays the clipped area, you need 1900x more RAM than a simple graphic.
Thats a waste of ressources dont you think ?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

No need to load the tileset more that once.

You can clip always a different region, before displaying it.
So in the Loop, or wherever you display your tiles, you always
use ClipSprite() to clip the part you want to display next, and then
DisplaySprite(). Before the next DisplaySprite() you just clip another region.

Timo




http://freak.coolfreepages.com/
Madman
New User
New User
Posts: 1
Joined: Fri Apr 25, 2003 8:08 pm

dooh :)

Post by Madman »

Why is that everyone is working against my tile-engine ? LMAO !!
Who was the one posting his example ? THCS i think ? Can you please repost ? Thx !!
THCM
Enthusiast
Enthusiast
Posts: 276
Joined: Fri Apr 25, 2003 5:06 pm
Location: Gummersbach - Germany
Contact:

Post by THCM »

Hi Madman,

again my example:

Given:
#SpritesID = Loaded Picture 24 Bit PNG 640x144
#SpritesX = 10 ;No of Sprites in a line
#SpriteSizeX = 64
#SpriteSizeY = 48

Animpointer = No of Sprite to display (0-29 there are 30 frames in the picture)

y = AnimPointer / #SpritesX * #SpriteSizeY
;y-pos of Sprite in loaded picture

x = (AnimPointer-((AnimPointer / #SpritesX) * #SpritesX)) * #SpriteSizeX

;x-pos of Sprite in loaded picture

ClipSprite (#SpritesID, x, y, #SpriteSizeX, #SpriteSizeY)

;sets the spriteclipping

DisplayTransparentSprite(#SpritesID, Xpos , Ypos)

;displays only the clipped sprite at xpos, ypos

The ClipSprite command only defines the source area in a larger picture, which will be blitted to the screen using a displaycommand.

I think it's not the usual way, but works fine and is very fast. There's no need to have a command you suggested! The ClipSprite is also very nice, if you want to draw always the same animationframe on the screen (Stars, Particles etc!)

Bye, Yours
The Human Code Machine / Masters' Design Group
Post Reply