Jump to content
IGNORED

Playfield bounderies help.


ioi_xd

Recommended Posts

First off, I'm aware that I should be posting here less and figuring things out on my own. That being I've been racking my head trying to find out what I'm doing wrong here.

I'm using the example from the stickied post to stop my character from moving through the playfield; this one, specifically. I'm using it how it was provided, only changing "player0" and "p_0" to "player1" and "p_1" respectively (the main character is player1). What's strange here is that it works in the program provided. But when I transfer it over to my own, it doesn't seem to work. I have no idea why. I've tried disabling the animation, removing some of the kernal options, resetting the playfield heights...but nothing seems to work here. The only thing that I haven't taken from the example are the player colors, since I have my own placed.

I'm aware that my code is very messy. I'll probably comment it later, but for now I'm just setting up a basic prototype.

default.bas

default.bas.bin

Edited by ioi_xd
Link to comment
Share on other sites

ioi_xd,

 

What happened to the other post with the star? That is how most people learn to include me. I would post any questions you have. They help others as well. I will take a look at it tomorrow if no one has by then. I'm not an expert like the others but I am able to work with some codes from time to time.

Link to comment
Share on other sites

It'd be something more like this

 

 

   rem Generated 4/12/2018 5:43:58 PM by Visual bB Version 1.0.0.548
   rem **********************************
   rem *<filename>                      *
   rem *<description>                   *
   rem *<author>                        *
   rem *<contact info>                  *
   rem *<license>                       *
   rem **********************************
 
   set tv ntsc
   set kernel_options player1colors no_blank_lines 
   set kernel_options pfheights
   set romsize 32kSC
   set optimization speed
   set smartbranching on
   set optimization noinlinedata
   set optimization inlinerand
 
   pfheights:
   8
   8
   8
   5
   5
   6
   6
   8
   8
   8
   8
end
 
   playfield:
   XXXXXXXXXXXXXX....XXXXXXXXXXXXXXX
   X...................X..........X
   X...................X..........X
   X..............................X
   X...................XXXXXXXXXXXX
   X..............................X
   X..............................X
   X..............................X
   X..............................X
   X..............................X
   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end
 
   COLUBK = 0
   COLUPF = 144
 
   f = 0
 
   player1x = 75 : player1y = 75
 
main
 
   if f = 2 then player1:
   %00000000
   %00011000
   %00011000
   %01111110
   %01111110
   %00011000
   %00011000
   %00000000
end
 
   if f = 4 then player1:
   %00000000
   %00110000
   %00110110
   %00011110
   %01111000
   %01101100
   %00001100
   %00000000
end
 
   if f = 6 then player1:
   %00000000
   %01100110
   %01100110
   %00011000
   %00011000
   %01100110
   %01100110
   %00000000
end
 
   if f = 8 then f = 0
   if f = 0 then player1:
   %00000000
   %00001100
   %01101100
   %01111000
   %00011110
   %00110110
   %00110000
   %00000000
end
 
   player1color:
   $40
   $42
   $44
   $46
   $48
   $4A
   $4C
   $4E
end
 
   drawscreen
   if collision(player1,playfield) then gosub knock_player_back
   x = 0 : y = 0
   if joy0right then x = 1
   if joy0left then x = -1
   if joy0up then y = -1
   if joy0down then y = 1
   player1x = player1x + x :  player1y = player1y + y
   if SWCHA < 240 then f = f + 1 : goto animationinc
animationinc
   goto main
 
knock_player_back
   player1x = player1x - x
   player1y = player1y - y
   return

PF_boundaries.bas

PF_boundaries.bas.bin

Link to comment
Share on other sites


The example code sets the player0x and player0y increments (P0_x, P0_y) according

joy0 then applies that movement (adds them to player0x, player0y)

does a drawscreen (which is when a collision is detected)

then, if there's a collision, reverses the movement (it subtracts P0_x, P0_y from

player0x, player0y)


I substituted player1x, player1y for player0x, player0y (in the example code)

and/or x and y (in your code) I couldn't see any reason not to use player1x, player1y

directly instead of x and y (doesn't mean you don't have one)

then substituted your x and y for P0_x and P0_y in the example code


that is to say x and y have the same roll as P0_x and P0_y which seemed to be what

you were trying to do.


I also zeroed x and y after the collision check. 'till then you (might) need them, after that

you either want them to be 0 or what ever joy0 indicates
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...