Jump to content
IGNORED

Weird issue in a function


swapd0

Recommended Posts

I've been playing a bit with 7800basic and I'm stuck with a weird error.

 

I've a function to check collisions with a 8x8 tile map, but since I'm using 16pixels zones the collision it's a bit weird because the tiles are 8x16 but they represents 4x8 tiles. hit_tile_xxx are arrays of data with a bitmask to check if you have to collided with the tile.

 

I've a big wall on the left side of the screen, if I move the sprite there and then move it vertically I get the background color changing, and it's weird because I'm testing with temp1 that holds x position and I'm not moving on x axis.

 

temp & 8 and temp & 4 are used to test if I'm in the left/upper or right/lower part of the tile.

 

It looks like temp1 it's smashed with temp2 somewhere...

 

Quote
; parameters, x, y
function tile_collision
  tx = temp1 / 8
  ty = temp2 / 16
  tile = peekchar(screen1map, tx, ty, 20, 12)
  if tile = 0 then return 0
  tile = tile / 2. ; because of doublewide
  char1 = tile. ; debug 
  if temp2 & 8 then hit = hit_tile_high[tile] else hit = hit_tile_low[tile]. ; A
  if hit && (temp1 & 4) then BACKGRND = $5f : hit = hit_tile_right[tile] else BACKGRND = $1f : hit = hit_tile_left[tile]. ; B
  return hit

 

Captura de pantalla 2021-02-15 a las 22.33.16.png

Edited by swapd0
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...