Jump to content
IGNORED

7800 Basic


Lavalamp

Recommended Posts

Unfortunately not. I thought of that, everything starts at x=0 and I even changed it to x=1 or x=5 and I still get the bizarre behaviour were parts of the sprite don't collide. Just to clarify, I added 'set collisionwrap on' too and nothing changed.

Link to comment
Share on other sites

  • 2 weeks later...
 set zoneheight 8
 set collisionwrap on

 dim playerx=a
 playerx=75
 playery=176
 dim playery=b

 dim platx=c
 c=142
 dim platy=d
 d=152

 dim platx2=g:platx2=platx-16
 dim platx3=h:platx3=platx-32
 dim platx4=i:platx4=platx-48

 dim prevx=e
 dim prevy=f

 incgraphic face1.png
 incgraphic plat.png

 rem ***' set the colors of palette 0, which we'll use to draw the happy face
  P0C1=$82
  P0C2=$48
  P0C3=$fb

main
 clearscreen

 prevx=playerx
 prevy=playery

 ;'joystick
 if joy0left  then playerx=playerx-1
 if joy0right then playerx=playerx+1
 if joy0down  then playery=playery+2
 if joy0up    then playery=playery-2
 ;if joy0fire0 then
 ;if joy0fire1 then

 ;'stop player moving off screen
 if playerx<1 then playerx=playerx+1
 if playerx>150 then playerx=playerx-1
 if playery<1 then playery=playery+2
 if playery>176 then playery=playery-2

 ;'COLLISION DETECTION
 ;'bottom right wall
 if playerx>prevx && boxcollision(playerx, playery, 8, 8, 94, platy, 64, 2) then playerx=playerx-1
 if playerx<prevx && boxcollision(playerx, playery, 8, 8, 94, platy, 64, 2) then playerx=playerx+1
 if playery>prevy && boxcollision(playerx, playery, 8, 8, 94, platy, 64, 2) then playery=playery-2
 if playery<prevy && boxcollision(playerx, playery, 8, 8, 94, platy, 64, 2) then playery=playery+2

 ;'bottom left wall
 if playerx>prevx && boxcollision(playerx, playery, 8, 8, 0, 152, 64, 2) then playerx=playerx-1
 if playerx<prevx && boxcollision(playerx, playery, 8, 8, 0, 152, 64, 2) then playerx=playerx+1
 if playery>prevy && boxcollision(playerx, playery, 8, 8, 0, 152, 64, 2) then playery=playery-2
 if playery<prevy && boxcollision(playerx, playery, 8, 8, 0, 152, 64, 2) then playery=playery+2:plotsprite plat 0 0 0

 ;'top left wall
 if playerx>prevx && boxcollision(playerx, playery, 8, 8, 15, 48, 64, 2) then playerx=playerx-1
 if playerx<prevx && boxcollision(playerx, playery, 8, 8, 15, 48, 64, 2) then playerx=playerx+1
 if playery>prevy && boxcollision(playerx, playery, 8, 8, 15, 48, 64, 2) then playery=playery-2
 if playery<prevy && boxcollision(playerx, playery, 8, 8, 15, 48, 64, 2) then playery=playery+2

 ;'top right wall
 if playerx>prevx && boxcollision(playerx, playery, 8, 8, 94, 48, 64, 2) then playerx=playerx-1
 if playerx<prevx && boxcollision(playerx, playery, 8, 8, 94, 48, 64, 2) then playerx=playerx+1
 if playery>prevy && boxcollision(playerx, playery, 8, 8, 94, 48, 64, 2) then playery=playery-2
 if playery<prevy && boxcollision(playerx, playery, 8, 8, 94, 48, 64, 2) then playery=playery+2

 ;' middle wall upper
 if playerx>prevx && boxcollision(playerx, playery, 8, 8, 79, 68, 32, 2) then playerx=playerx-1
 if playerx<prevx && boxcollision(playerx, playery, 8, 8, 79, 68, 32, 2) then playerx=playerx+1
 if playery>prevy && boxcollision(playerx, playery, 8, 8, 79, 68, 32, 2) then playery=playery-2
 if playery<prevy && boxcollision(playerx, playery, 8, 8, 79, 68, 32, 2) then playery=playery+2

 ;' middle wall lower
 if playerx>prevx && boxcollision(playerx, playery, 8, 8, 22, 120, 32, 2) then playerx=playerx-1
 if playerx<prevx && boxcollision(playerx, playery, 8, 8, 22, 120, 32, 2) then playerx=playerx+1
 if playery>prevy && boxcollision(playerx, playery, 8, 8, 22, 120, 32, 2) then playery=playery-2
 if playery<prevy && boxcollision(playerx, playery, 8, 8, 22, 120, 32, 2) then playery=playery+2


;' debug line, draws a line in the top right of the screen when player hits the bottom left line
 if boxcollision(playerx, playery, 8, 8, 20, 120, 32, 2) then plotsprite plat 0 0 0

 plotsprite face1 0 playerx playery

 ;'DRAWING WALLS
 plotsprite plat 0 platx platy
 plotsprite plat 0 platx2 platy
 plotsprite plat 0 platx3 platy
 plotsprite plat 0 platx4 platy

 plotsprites plat 0 0 platy
 plotsprites plat 0 16 platy
 plotsprites plat 0 32 platy
 plotsprites plat 0 48 platy

 ;'enemy base walls
 plotsprites plat 0 0 48
 plotsprites plat 0 16 48
 plotsprites plat 0 32 48
 plotsprites plat 0 48 48

 plotsprites plat 0 142 48
 plotsprites plat 0 126 48
 plotsprites plat 0 110 48
 plotsprites plat 0 94 48

 ;'middle walls
 plotsprites plat 0 79 68
 plotsprites plat 0 95 68

 plotsprites plat 0 22 120
 plotsprites plat 0 38 120

 drawscreen
 goto main

Pff, it's already been over 10 days. Sorry for the delay, I'm hoping to carve out some time soon to work on this consistently soon but not there yet. If you still even remember what we were talking about and are interested, I would appreciate the help, thanks for the offer. I just hope it's not something embarrassingly simple, though that's what it feels like it will turn out to be to be honest. I hope you don't mind me posting it all, I figured it would probably take me longer to explain it than to just write out the entire code.

Edited by Dalta
Link to comment
Share on other sites

Ok, you've done nothing wrong, but it seems you've run up against the limits of the boxcollision function. It was always intended for sprite sized objects (it's under the heading "sprite collisions with boxcollision" in the manual) and objects wider than 48 pixels cause certain checks to break.

 

I could squeeze in larger objects by adding in a bunch of checks, or switching to 16-bit math, but it would complicate the routine a fair bit. It's designed to be as lean as possible, so as not to bog down games with typical requirements.

 

I'll update the docs with the boxcollision limitation next chance I get.

 

For your project, I'd recommend you use peekchar to look for tiles at certain points under your sprite. There's more on that here.

 

For one thing I noticed, I don't think 7800Basic recognizes "plotsprites" unless it's something new that's been added recently.

Nice catch. I think the parser is just taking it as a "plotsprite" command. More homework for me. :)

Link to comment
Share on other sites

Thanks a lot guys for the help. Yes, I thought about making a tile map originally, but I was just trying to get something quick and dirty up and running. Thanks for the link, I will go through and reformulate the code with its help. Edit: Ah, I've seen that link before haha, I was planning to come back to tiles and that after getting this game going, it looks my hand has been forced :)

Edited by Dalta
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...