View Single Post
Old 27 November 2020, 18:47   #87
colinvella
Registered User
 
colinvella's Avatar
 
Join Date: Dec 2019
Location: Marsa
Posts: 23
Quote:
Originally Posted by buzzybee View Post
Wow, just saw this for the very first time. So this coded in Blitz Basic for AGA-Amiga, right? Beautiful. You are making really good progress here.

How do you guys handle collision on curved surfaces and video priority switching for the main character?
Collisions on curved and slanted surfaces are implemented with the help of lookup tables that map the Y offset of the surface within the tile (between 0 and 15px) for every x pixel offset within the tile. So instead of assuming that the boundary of a solid tile is always the top (y = 0), it is computed based on the X value and the collision logic is done accordingly. To handle some edge cases (like at the bottom of the ramp where the ramp "slice" is really thin and easy to miss e.g. when falling), there is a special marker tile that "pushes" the player up onto the ramp. It's aim it to provide more surface area to capture the collision.

As for video priority, since the main character is a hardware sprite, it is possible to manipulate a specific video register to control whether the sprite should appear on top of all dual playfield layers, between them, or behind both.

This is a snippet from my code. There are special market tiles (I keep an invisible layer for collision detection, enemy placement, showing the player behind the foreground etc.).

Code:
    fc.b = GetFuncTile{\tx, cy}
    If !IsBehind{fc.b} <> \isBehind
      ; BPLCON2 and BPLCON4 XORed, must keep BPLCON3 to $1C00 due to sprite palette
      DisplayControls #CPL_MAIN, $0004, $1C00, $0
      \isBehind = NOT \isBehind
    EndIf
colinvella is offline  
 
Page generated in 0.04300 seconds with 11 queries