ioi_xd Posted April 17, 2018 Share Posted April 17, 2018 (edited) 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 April 17, 2018 by ioi_xd Quote Link to comment Share on other sites More sharing options...
+Lewis2907 Posted April 17, 2018 Share Posted April 17, 2018 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. Quote Link to comment Share on other sites More sharing options...
bogax Posted April 17, 2018 Share Posted April 17, 2018 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 Quote Link to comment Share on other sites More sharing options...
ioi_xd Posted April 18, 2018 Author Share Posted April 18, 2018 -snip- Thanks, that seems to work! Would you mind telling me specifically what you changed, though? I see some differences in the last part but that doesn't seem to be exactly what's changed here. Quote Link to comment Share on other sites More sharing options...
bogax Posted April 18, 2018 Share Posted April 18, 2018 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 Quote Link to comment Share on other sites More sharing options...
+Lewis2907 Posted April 19, 2018 Share Posted April 19, 2018 ioi_xd, Per your request is the program that made some adjustments to. I would go with Bogax program as it looks to be more polished than what I did. The SWCHA portion is something I am still learning myself. Hope this helps you out with your game, thanks. 20180415_ioi_xd.txt 20180415_ioi_xd.bas.bin Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.