realbasic-games
[Top] [All Lists]

Subclass & Instance..tiles and Sprite Surface

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Subclass & Instance..tiles and Sprite Surface
From: Eric <cire- at prodigy dot net>
Date: Mon, 28 Jul 2003 13:20:56 -0500
>
> Do this:
> 1) Create a SpriteSurface subclass if you haven't already. You really
> should that way you can reuse the code from project to project very
> easily.
>
> 2) Put this in the PaintTile event of the subclass after defining
> TileHeight and TileWidths as constants or properties.
>
>    /////////////////////////////////////////
>    //       Contributed by Joe Strout     //
>    /////////////////////////////////////////
>
>    Dim startcol, endcol, startrow, endrow As Integer
>    Dim row, col As Integer
>    Dim worldX, worldY As Integer
>    Dim dx, dy As Integer
>
>    if TileWidth > 0 and TileHeight > 0 then
>      worldX = xpos * 64
>      worldY = ypos * 64
>      startcol = worldX / TileWidth
>      startrow = worldY / TileHeight
>      endcol = (worldX + 63) / TileWidth
>      endrow = (worldY + 63) / TileHeight
>
>      dy = startrow * TileHeight - worldY
>      for row = startrow to endrow
>        dx = startcol * TileWidth - worldX
>        for col = startcol to endcol
>          PaintTile g, dx, dy, row, col
>          dx = dx + TileWidth
>        next
>        dy = dy + TileHeight
>      next
>
>    else
>      PaintTile g, xpos, ypos, row, col
>    end if
>
> 3) Then put this in the instance:
>
>    dim p as picture
>
>    p = SWWorld1.map.GetTile(row, column)
>
>    if p <> nil then
>      if xpos > 0 and ypos > 0 and xpos < me.SurfaceWidth and ypos <
> me.SurfaceHeight then
>        g.drawpicture p, xpos, ypos
>      end if
>    end if
>
> (I've rewritten that last bit of code several times so I'm not sure if
> it's absolutely correct.)
> You should obviously modify the instance code to suit your needs but
> you should only need to modify the second line.
>
>

Ok so I make a class called Game_Surface and then make its
super Sprite Surface?

Now this may be a dumb question but umm..how do make
and instance of it?

I haven't really made a subclass and instance..
Well I have changed a classes super to thread...



---
A searchable archive of this list is available at:
<http://support.realsoftware.com/listarchives/search.php>

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


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