[Gambas-user] gb3: Draw method with same source and destination image

Benoît Minisini gambas at ...1...
Thu Feb 3 02:14:18 CET 2011


> On 02/02/2011 07:00 PM, Benoît Minisini wrote:
> > Actually you want some sort of scrolling?
> 
> Yes, although the image "shifting" I spoke of isn't what creates the
> scrolling directly. Here's a brief breakdown of what happens in the game.
> 
> The server has a map 65536x65536 tiles, with each tile representing one
> square foot. This map is organized into "cells", which are 32x32 tiles
> each. When a client connects, the server sends the client a "cell grid"
> of 3x3 cells, with the center cell being the cell the player is located
> in. When the player moves outside the center cell, all the cells are
> shifted accordingly and the server sends the player the data for the new
> cells.
> 
> The client uses a DrawingArea of 1280x720 pixels to represent the final,
> visible rendering of the world, but a "tile grid" image buffer is used
> to composite the scene invisibly. While the cell grid is just landscape
> data in arrays, the tile grid is a graphical representation of a subset
> of the cell grid data. The tile grid is a square grid of tiles designed
> to be a few tiles larger than the DrawingArea. Each tile is 128x128
> pixels. If the DrawingArea is 1280x720 then the tile grid is 1408x1408
> (11x11 tiles, with the player being in the center tile). The tile grid
> is treated like an old-school RPG; when the player moves out of the
> center tile the image is shifted one tile and a new row of tiles is
> drawn. The player doesn't see this, however, as the DrawingArea is
> updated from the tile grid by a camera that smoothly follows the player.
> 
> I would use SDL but it isn't currently robust enough to support the
> effects I need (discussed in a previous email; no one has the time
> currently to expand it). OpenGL, while nice, is complex enough that it
> would prevent me from finishing the game. I'm doing all the design,
> coding and artwork by myself (a friend is doing the music). So that
> leaves me with pushing gb.image and gb.image.effect to their limits.
> 
> I'm almost to the point where I can record a video of the game in
> action, so soon I'll be able to show you what I'm doing. Until then,
> just struggling with frame rates. ;)

Maybe you can speed up things a little by intelligently using the X11 design.

In Gambas 3, if you use a DrawingArea with the Cached property set, the 
DrawingArea maintains a pixmap on the X11 server that is used as the 
background pixmap of the X11 window. That means that the DrawingArea is 
automatically refreshed by the X11 server.

Then, if you put a big DrawingArea inside a smaller Panel (or another 
DrawingArea, because you can ensure that it will not drawing anything), you 
can create the scrolling of the center cell just by moving it with the Move() 
method. The X11 server will do all the display, without any processing in your 
application.

Of course, when you reach one extremity of the inner DrawingArea, you must 
then do a real scrolling and update its contents.

I don't know if you do that already. But if you didn't, it may speed things 
up.

Regards,

-- 
Benoît Minisini




More information about the User mailing list