Rabbit 2600 Posted May 27, 2013 Share Posted May 27, 2013 Well, I'm doing a platformer similar to SonSon, since I think the Atari 2600 should sport such a game since SonSon is a really great arcade game. I have animated the player and he can run back and forward in true SonSon fashion! But, we need more then that. In SonSon there are different platforms above and under you. And I want the player to be able to shift between them by pressing up and down. However I can't get it to work right. For moving left and right I use this code: if joy0right then x=x+1 if joy0left then x=x-1 I atempted using if joy0up then y=y+5 But that dosn't work. I need the player to "teleport" to the level above him by pressing up, and below him by pressing down. What do I do? My project is attached if my explanation is confusing. default.bas.bin Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted May 27, 2013 Share Posted May 27, 2013 Try this using the variable a. If a is already being used then use another one. if joy0up && !a{0} then y=y-32 : a{0}=1 if !joy0up && a{0} then a{0}=0 if joy0down && !a{1} then y=y+32 : a{1}=1 if !joy0down && a{1} then a{1}=0 What this does is this makes the guy go up once, but only once as long as the button (or joystick) is held up. When the joystick is released, he can move up again. You should also post your bB code (the file that ends in .bas) for help, too, so we can know what you're doing. Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 27, 2013 Author Share Posted May 27, 2013 Neat, I'll tinker with the code you gave me and see if I can come to some solution =) This is my code so far: rem Generated 2013-05-27 22:17:41 by Visual bB Version 1.0.0.554 rem ********************************** rem *<filename> * rem *<description> * rem *<author> * rem *<contact info> * rem *<license> * rem ********************************** x=50 y=40 main playfield: ................................ ................................ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ................................ ................................ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ................................ ................................ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ................................ ................................ end COLUP0=$28 COLUBK=$02 f=f+1 if f=10 then player0: %00011000 %00011000 %00111100 %00111100 %00000000 %00011000 %00011000 %00000000 end if f=20 then player0: %01000010 %00100100 %01011000 %01111110 %00000010 %00011000 %00011000 %00000000 end if f=20 then f=0 player0x=x player0y=y drawscreen if joy0right then x=x+1 if joy0left then x=x-1 if joy0up && y=40 then y=16 if joy0down && y=16 then y=40 goto main And here is the program: default.bas Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted May 27, 2013 Share Posted May 27, 2013 Instead of using x and y for player0's x and y places, you can just use player0x and player0y (i.e. player0x=player0x+1) Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted May 27, 2013 Share Posted May 27, 2013 Would this work in progress be helpful at all? atariage.com/forums/topic/179473-fake-gravity-platformer-test/ Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 28, 2013 Author Share Posted May 28, 2013 (edited) Thanks for all tips! The WIP is a great help! I think I'm gonna fix it now =) Now, another question - How do I make it so that at random intervals a ball object or p1 comes in from the right on a randomly chosen position where it chooses from 3 xy locations? I understand I need a random number generator, but I don't quite know how to set it up so the generator chooses between 3 numbers. Like, if it landed on 1, then player1 position would be y:40 and x:90 for example and then move to the left. And when it exits the screen it resets. I made the start of a code, it randomly places player1, but it always does it all the time so the enemy is at 3 places at the same time, any tips on how to fix this? =) a = (rand&3) if a = 1 then player1y=40:player1x=90 if a = 2 then player1y=16:player1x=90 if a = 3 then player1y=64:player1x=90 My full code: rem Generated 2013-05-27 22:17:41 by Visual bB Version 1.0.0.554 rem ********************************** rem *<filename> * rem *<description> * rem *<author> * rem *<contact info> * rem *<license> * rem ********************************** set smartbranching on x=50 y=40 main playfield: ................................ ................................ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ................................ ................................ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ................................ ................................ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ................................ ................................ end COLUP0=$28 COLUBK=$02 f=f+1 g=g+1 if f=10 then player0: %00001100 %00011100 %00001010 %00101100 %00101100 %00010000 %01100000 %00000000 end if f=20 then player0: %00001010 %00011100 %00001010 %00001100 %01101100 %00010000 %01100000 %00000000 end if f=20 then f=0 if g=10 then player1:: %11111111 %10000001 %10111101 %10000001 %10100101 %10000001 %01000010 %00111100 end if g=20 then player1: %11111111 %10000001 %10001111 %10000001 %10001011 %10000001 %01000010 %00111100 end if g=30 then player1: %11111111 %10000001 %10000001 %10000001 %10000001 %10000001 %01000010 %00111100 end if g=40 then player1: %11111111 %10000001 %11110001 %10000001 %11010001 %10000001 %01000010 %00111100 end if g=40 then g=0 player0x=x player0y=y a = (rand&3) if a = 1 then player1y=40:player1x=90 if a = 2 then player1y=16:player1x=90 if a = 3 then player1y=64:player1x=90 drawscreen if joy0right then x=x+1 if joy0left then x=x-1 if joy0up && y=40 then y=16 if joy0down && y=16 then y=40 goto main Edited May 28, 2013 by Rabbit 2600 Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 28, 2013 Author Share Posted May 28, 2013 (edited) Hm, I get a syntax error everywhere now, what's going on? rem Generated 2013-05-27 22:17:41 by Visual bB Version 1.0.0.554 rem ********************************** rem * * rem * * rem * * rem * * rem * * rem ********************************** set smartbranching on x=50 y=40 main playfield: ................................ ................................ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ................................ ................................ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ................................ ................................ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ................................ ................................ end COLUP0=$28 COLUBK=$02 f=f+1 g=g+1 if f=10 then player0: %00001100 %00011100 %00001010 %00101100 %00101100 %00010000 %01100000 %00000000 end if f=20 then player0: %00001010 %00011100 %00001010 %00001100 %01101100 %00010000 %01100000 %00000000 end if f=20 then f=0 if g=10 then player1:: %11111111 %10000001 %10111101 %10000001 %10100101 %10000001 %01000010 %00111100 end if g=20 then player1: %11111111 %10000001 %10001111 %10000001 %10001011 %10000001 %01000010 %00111100 end if g=30 then player1: %11111111 %10000001 %10000001 %10000001 %10000001 %10000001 %01000010 %00111100 end if g=40 then player1: %11111111 %10000001 %11110001 %10000001 %11010001 %10000001 %01000010 %00111100 end if g=40 then g=0 player0x=x player0y=y a = (rand&3) if a = 1 then player1y=40:player1x=90 if a = 2 then player1y=16:player1x=90 if a = 3 then player1y=64:player1x=90 drawscreen if joy0right then x=x+1 if joy0left then x=x-1 if joy0up && y=40 then y=16 if joy0down && y=16 then y=40 goto main Edited May 28, 2013 by Rabbit 2600 Quote Link to comment Share on other sites More sharing options...
RevEng Posted May 28, 2013 Share Posted May 28, 2013 Just glancing at it, one of your player1: statements has an extra colon. Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 28, 2013 Author Share Posted May 28, 2013 (edited) Ah, cheers! I removed the extra colon, but I still get a syntax error =/ I fixed the syntax errors I think. I added a space before every end. But now I get a blackscreen when I try to run the program >_< rem Generated 2013-05-27 22:17:41 by Visual bB Version 1.0.0.554 rem ********************************** rem * * rem * * rem * * rem * * rem * * rem ********************************** set smartbranching on x=50 y=40 main playfield: ................................ ................................ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ................................ ................................ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ................................ ................................ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ................................ ................................ end COLUP0=$28 COLUBK=$02 f=f+1 g=g+1 if f=10 then player0: %00001100 %00011100 %00001010 %00101100 %00101100 %00010000 %01100000 %00000000 end if f=20 then player0: %00001010 %00011100 %00001010 %00001100 %01101100 %00010000 %01100000 %00000000 end if f=20 then f=0 if g=10 then player1: %11111111 %10000001 %10111101 %10000001 %10100101 %10000001 %01000010 %00111100 end if g=20 then player1: %11111111 %10000001 %10001111 %10000001 %10001011 %10000001 %01000010 %00111100 end if g=30 then player1: %11111111 %10000001 %10000001 %10000001 %10000001 %10000001 %01000010 %00111100 end if g=40 then player1: %11111111 %10000001 %11110001 %10000001 %11010001 %10000001 %01000010 %00111100 end if g=40 then g=0 player0x=x player0y=y a = (rand&3) if a = 1 then player1y=40:player1x=90 if a = 2 then player1y=16:player1x=90 if a = 3 then player1y=64:player1x=90 drawscreen if joy0right then x=x+1 if joy0left then x=x-1 if joy0up && y=40 then y=16 if joy0down && y=16 then y=40 goto main Edited May 28, 2013 by Rabbit 2600 Quote Link to comment Share on other sites More sharing options...
RevEng Posted May 28, 2013 Share Posted May 28, 2013 Put them back as before. "end" needs to be at the beginning of the line, with no indent. I'm not sure if it's the forum reformatting your text, but there appears to be unindented COLUP0 and COLUBK assignments. Add some white space to the left of those if they don't have any. Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 28, 2013 Author Share Posted May 28, 2013 (edited) Ah! Cheers, it's working now! Haha, random errors, they are the hardest Anyway, on the question about having enemies (player1) coming in from the right and moving to the left from a randomly chosen position. How would I go about that? I did this as a start: a = (rand&2) if a = 1 then player1y=57:player1x=137 if a = 2 then player1y=32:player1x=137 Source: default.bas Atempted to add movement to player1 but it didn't do me any good. Hm. . . if player1x < player0x then player1x = player1x+1 if player1x > player0x then player1x = player1x+1 if player1y < player0y then player1x = player1x+1 if player1y > player0y then player1x = player1x+1 player1x = player1x:player1x = player1x I'm after a sort of enemy movement like in Oystron Edited May 28, 2013 by Rabbit 2600 Quote Link to comment Share on other sites More sharing options...
bogax Posted May 28, 2013 Share Posted May 28, 2013 (edited) Ah! Cheers, it's working now! Haha, random errors, they are the hardest Anyway, on the question about having enemies (player1) coming in from the right and moving to the left from a randomly chosen position. How would I go about that? I did this as a start: a = (rand&2) if a = 1 then player1y=57:player1x=137 if a = 2 then player1y=32:player1x=137 & is a bitwise and meaning corresponding bits in the two operands are anded together 1 & x = x 0 & x = 0 2 is %00000010 rand %hgfedcba rand & 2 = %000000b0 think of the letters as variables for individual bits in particular positions in the byte rand & 2 = %000000b0 b can be 1 or 0 so the result of rand & 2 will equal 2 or 0 1 in the b bit positon is equal to 2 that is 2 in binary is %00000010 rand & 2 will never be 1 as in %0000001 which is what if a = 1 then ... tests for your code should be if a = 0 then player1y=56:player1x=137 if a = 2 then player1y=32:player1x=137 I assume that means player1x will always get set to 137 so there's no need to set it conditionally so you could do it this way player1x=137 if a = 0 then player1y=56 if a = 2 then player1y=32 if you write if a then ... its the same as if a<>0 then ... and since you only have two possibilities you could write your code like this player1x=137 if a then player1y = 32 else player1y = 56 this way you only do one if then statement with the others you always do two even though only one can be true. edit using the else ends up as if you'd written if a then player1y = 32 : goto skip player1y = 56 skip it saves you an if statement but costs you the equivalent of a goto personaly I would use a table look up for this situation although it doesn't save you much if anything with only two possibilities a = rand & 1 player1x = 137 player1y = tbl[a] data tbl 56, 32 end Edited May 28, 2013 by bogax Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 28, 2013 Author Share Posted May 28, 2013 (edited) Cool! Cheers! That seemed a lot simpler then the way I made it =) I'm still getting the hang of making things tidy and effective. How would I go about with the movement of player1? If I understand things correctly, I need to set up a timer, and a random event. So that every 2 seconds there is a chance for player 1 to be positioned at either y32 or y56. And then initiate the movement? Edited May 28, 2013 by Rabbit 2600 Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted May 28, 2013 Share Posted May 28, 2013 By the title I was expecting something else 1 Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted May 28, 2013 Share Posted May 28, 2013 When using a timer (e.g. a=a+1), when a reaches 60, it would be one second. So once a would reach 120 (i.e. a>119), that would take 2 seconds. Quote Link to comment Share on other sites More sharing options...
bogax Posted May 28, 2013 Share Posted May 28, 2013 Cool! Cheers! That seemed a lot simpler then the way I made it =) I'm still getting the hang of making things tidy and effective. How would I go about with the movement of player1? If I understand things correctly, I need to set up a timer, and a random event. So that every 2 seconds there is a chance for player 1 to be positioned at either y32 or y56. And then initiate the movement? you could increment a counter every time you do a drawscreen so it gets incremented ~30 times a second then mask for the lower 6 bits and mess with player1 if they're 0 which they will be every 64 counts (a little more than 2 seconds) something like drawscreen counter = counter + 1 . . . temp1 = counter & 63 if !temp1 then mess with player1 Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 28, 2013 Author Share Posted May 28, 2013 (edited) I think I understand. Cheers! Now, to make the enemy move, would this be correct? player1x=137+1 Edited May 28, 2013 by Rabbit 2600 Quote Link to comment Share on other sites More sharing options...
bogax Posted May 28, 2013 Share Posted May 28, 2013 (edited) oops sorry I forgot we're not all english speakers (or 'mericun or what ever that would be) It just means do whatever you're going to do with player1 (I'm not really sure what you want to do) edit (with reference to previous posts) I'm guessing it would be something like temp1 = counter & 63 if !temp1 then temp2 = rand & 1 : player1y = tbl[temp2] Edited May 28, 2013 by bogax Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted May 28, 2013 Share Posted May 28, 2013 Actually, it would be player1x=player1x+1, since you need to tell the program what variable you want to increase. Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 28, 2013 Author Share Posted May 28, 2013 Ah, okay. Haha, Thought it was some strange new command. Haha, I was a bit slowminded =) Hm, I'll do my best and try to explain in a simple way, I find it hard to explain things in english. What I'm going for is, there are 2 lines on the playfield where the player can run on. I'm trying to do so that at random intervals an enemy (in this case player1) goes from the right to the left. Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 28, 2013 Author Share Posted May 28, 2013 (edited) Ah, cheers for the command! Hm, but I can't get it to work quite right. The player1 moves a pixel when the program starts then stops. Sorry if I'm frustrating you, I'm a bit of a slow learner. Would this be correct coding? counter = counter + 1 temp1 = counter & 63 if !temp1 then player1y = 32 && player1x=player1x+1 Edited May 28, 2013 by Rabbit 2600 Quote Link to comment Share on other sites More sharing options...
bogax Posted May 28, 2013 Share Posted May 28, 2013 Hm, I'll do my best and try to explain in a simple way, I find it hard to explain things in english. What I'm going for is, there are 2 lines on the playfield where the player can run on. I'm trying to do so that at random intervals an enemy (in this case player1) goes from the right to the left. now I'm confused perhaps I'm mixing up to seperate lines of discussion here. previously you said How would I go about with the movement of player1? If I understand things correctly, I need to set up a timer, and a random event. So that every 2 seconds there is a chance for player 1 to be positioned at either y32 or y56. And then initiate the movement? but 2 seconds is not a random interval and y is up-down not left-right Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 28, 2013 Author Share Posted May 28, 2013 Mm, okay. In short, I want player1 to go to the left as soon as it's on the screen Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted May 28, 2013 Share Posted May 28, 2013 (edited) The problem with using temp variables is that they reset after every drawscreen. So you'd need to use one of the a-z ones. So it would look something like this: dim counter=a counter=counter+1 if counter=64 then player1y=32 : player1x=player1x+1 but that would just move the player1x position by one, so instead, I would do this: dim counter=a if counter<64 then counter=counter+1 if counter=64 then player1y=32 : player1x=136 : counter=65 if counter=65 && player1y=32 && player1x>20 then player1x=player1x-1 This would make player 1 move left once the counter reaches 64 (approx. 1 second) and keep making player1 move left until it gets to the end. Also, you would need to tell the computer where player1x would start since you hadn't before (unless it's somewhere in your code before you typed this in.) Also, if you didn't put the counter at 65 after it reached 64, then player1 would just stand still. What the dim command does is so you can name your variables more descriptive names instead of letters. Edited May 28, 2013 by atari2600land Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 28, 2013 Author Share Posted May 28, 2013 I see! I set the player1 starting point at x137 and y56. I added your code but my program goes black when I try it out. Here's everything: rem Generated 2013-05-27 22:17:41 by Visual bB Version 1.0.0.554 rem ********************************** rem *<filename> * rem *<description> * rem *<author> * rem *<contact info> * rem *<license> * rem ********************************** dim counter=a x=50 y=56 main playfield: ................................ ................................ ................................ ................................ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ................................ ................................ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ................................ ................................ ................................ end COLUP0=$28 COLUP1=$20 COLUBK=$00 COLUPF=$D4 f=f+1 if f=10 then player0: %00011000 %00011000 %00111100 %00111100 %00000000 %00011000 %00011000 %00000000 end if f=20 then player0: %01000010 %00100100 %01011000 %01111110 %00000010 %00011000 %00011000 %00000000 end if f=20 then f=0 g=g+1 if g=10 then player1: %11111111 %10000001 %10111101 %10000001 %10100101 %10000001 %01000010 %00111100 end if g=20 then player1: %11111111 %10000001 %11111001 %10000001 %11001001 %10000001 %01000010 %00111100 end if g=30 then player1: %11111111 %10000001 %10000001 %10000001 %10000001 %10000001 %01000010 %00111100 end if g=40 then player1: %11111111 %10000001 %10000001 %10000001 %10000001 %10000001 %01000010 %00111100 end if g=50 then player1: %11111111 %10000001 %10011111 %10000001 %10010011 %10000001 %01000010 %00111100 end if g=50 then g=0 player1x=137 player1y=56 a = (rand&2) player1x=137 if a then player1y = 32 else player1y = 56 if player0x:player0y player0x=x player0y=y if counter<64 then counter=counter+1 if counter=64 then player1y=32 : player1x=136 : counter=65 if counter=65 && player1y=32 && player1x>20 then player1x=player1x-1 drawscreen if joy0right then x=x+1 if joy0left then x=x-1 if joy0up && y=56 then y=32 if joy0down && y=32 then y=56 skipmovement goto main 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.