realbasic-games
[Top] [All Lists]

Re: Spritesurface's Paint Tile method not working as advertised

To: realbasic-games at lists dot realsoftware dot com
Subject: Re: Spritesurface's Paint Tile method not working as advertised
From: Jose Lopez <pepelosoft at pepelosoftware dot com>
Date: Mon, 13 Dec 2004 19:44:24 -0500
Delivered-to: realbasic-games at lists dot realsoftware dot com
References: <20041213180024 dot 113535CC549 at lists dot realsoftware dot com>

On Dec 13, 2004, at 1:00 PM, realbasic-games-request at lists dot realsoftware dot com wrote:

 But in my code, despite putting g.useOldRenderer=true everywhere,
even on the toilet-paper, it still will not run properly. All the
new tiles get drawn to the top left corner and scrolling is choppy.

My project is a bit more complicated than the examples, since I have
the spritesurface, which is the main playing area, and a canvas
which displays a small overhead map of the whole game area, which is
much larger than the spritesurface can show.

Where is this canvas?  You don't have these controls overlapping, do
you?  That would be very bad mojo.  Assuming the canvas is not
touching the SpriteSurface, I can't imagine that would be involved.

Well, I have found the source of the problem. The thing is, the small overview map (which is a canvas named 'map') holds a picture which is a representation of the game world, with parts land and parts sea/water. In the PaintTile method I tried to directly read from that canvas map using the Pixel command, and according to the 'blue' value of the rgb color of that certain pixel draw a land or a water tile (at this moment, just a blunt green or blue box). This somehow upsets the garphics renderer and results in wired tile updates. These are the relevant lines of code inside the paintTile method (when commenting them out, everything works as a charm).

  dim c as color

c=map.Backdrop.Graphics.Pixel ((globalX)+xpos,(globalY)+ypos) //read the color of the pixel at the global map position

if c.blue<150 then // if the pixel on the map is not ocean, draw a green land box
    g.ForeColor=RGB(0,180,0)
    g.FillRect 0,0,63,63
  end if

Following code is used to verify the proper working of the painTile method:

  g.ForeColor = RGB(190,80,0)
  g.DrawRect 0,0,64,64
  g.DrawString str(xpos)+","+str(ypos), 10,12

As said before, when commenting the upper lines of code out, the lower part works as expected, when not, I get wired tile placements, usually all in the upper left corner of the spritesurface. Don't know if I am doing something wrong or if this would work for example in OS 9, where the Quartz engine would not 'interfere' and void the need for 'useoldrenderer' compliant code.

I was hoping to use this simple shortcut for holding a map in a picture, since it would void the need to store a virtual digital map in memory (as in a two dimensional matrix or array) and spare the need to draw that map twice everytime, once to the main playing area (spritesurface) and another to the small overview map (canvas). I was aditionally hoping to enable the player to create own custom maps using just a conventional drawing program, by simply drawing overview maps and then have the game transpose those directly into the main playing area on the fly.

I would appreciate any suggestions or comments. Perhaps the solution is quite simple and I just don't see it.

Greets,
Jose






_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>