realbasic-games
[Top] [All Lists]

Re: Double Buffer

To: realbasic-games at lists dot realsoftware dot com
Subject: Re: Double Buffer
From: Eric Richards <erockus at juno dot com>
Date: Sat, 27 Nov 2004 13:41:43 -0600
Delivered-to: realbasic-games at lists dot realsoftware dot com
> >I've been looking over the Three Ways to Animate.rb
> >project and I've got something working but I had to use
> >two buffer's, Buffer and Buffer2 (for canvas). Is that normal?
> 
> No, only one buffer is required for double-buffering.  There was a 
> sample project that goes along with the article; have you examined 
> that?

Yes I have that. However I don't have the article.

Well maybe I'm not doing things right...
In order to a "background" image I have to assemble it from
my tiles which comes from the Map data. Ok so I do that and
put it in to Buffer.

Now before I added Buffer2 the character wouldn't "erase" correctly.
So I added Buffer2 which has the same thing as Buffer but nothing is
drawn
to Buffer2. Its more or less a reference. 

This might be easier to show than explain..


> 
> >This test project is an overhead view type thing and I'm
> >having a little problem with the test character. I can't quite
> >get him to stop at the right spot when there is a bush, wall, etc.
> >in his way.
> 
> How are you doing the collision detection?  I don't think you'll be 
> able to get much help unless you show us what you're doing.

Humm well I basically say , hey Map give me the TileID at this
location in layer 3. Then if its a tile that is a bush, wall, etc.. I
shouldn't
go past it. Well thats the idea anyway. Here is what I have :

  if Keyboard.AsyncKeyDown(&h7E)  then //UP
    if TileIDAtXY(3,(knight.x\32),(knight.y-6)\32) =37  Then
      return
    end if
    Knight.frameIndex = ((Knight.FrameIndex+1) mod 3) + 3
    Knight.y = Knight.y -6
    
  END IF
  if Keyboard.AsyncKeyDown(&h7D) then // DOWN
    if TileIDAtXY(3,(knight.x\32),(knight.y+32)\32) =37 then
      return
    end if
    Knight.frameIndex =((Knight.FrameIndex+1)mod 3) 
    Knight.y = Knight.y + 6
  end if
  If Keyboard.AsyncKeyDown(&h7c) then //Right
    if TileIDAtXY(3,(knight.x+32)\32,knight.y\32) =37 then
      return
    end if
    Knight.frameIndex =((Knight.FrameIndex+1)mod 3) + 6
    Knight.x = Knight.x + 6
  end if
  if Keyboard.AsyncKeyDown(&h7b) then //left
    if TileIDAtXY(3,(knight.x-6)\32,knight.y\32) =37 then
      return
    end if
    Knight.frameIndex =((Knight.FrameIndex+1)mod 3) + 9
    Knight.x = Knight.x - 6
  end if

Note - I did change the character's size to 32x32 which seemed to help 
a bit but still isn't perfect.

Now that I think about it I guess I should be checking if TileIDAtXY > 0,
but that doesn't matter right now. Just need to get the collision
working.

I'm close I can taste it!

Thanks

Eric


"It's time once again for another Good Idea/Bad Idea"

________________________________________________________________
Juno Platinum $9.95. Juno SpeedBand $14.95.
Sign up for Juno Today at http://www.juno.com!
Look for special offers at Best Buy stores.
_______________________________________________
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>