bogax Posted May 28, 2013 Share Posted May 28, 2013 (edited) Mm, okay. In short, I want player1 to go to the left as soon as it's on the screen so you want player1 to change it's x position continuously you need to update the position continuously (every drawscreen I guess) so you'd keep a delta x position, a velocity basically, and add it to the player1x position every drawscreen. dim vx = x vx = -1 . . . player1x = player1x + vx drawscreen you could just increment player1x but then you need a seperate statement to decrement player1x if you want to go right 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 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. I think the problem is here: if player0x:player0y player0x=x player0y=y Maybe if you removed the "if player0x:player0y" line it would work. Also, the tag in the forum software doesn't like more than one space in front of text, so what would be really helpful is to post the .bas file along with your post. Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 28, 2013 Author Share Posted May 28, 2013 (edited) Alright. Here's the bas: default.bas Okay, making small progress. I got your dim counter code in and the program runs. Huzzah! But still no movement in player1 Edited May 28, 2013 by Rabbit 2600 Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted May 28, 2013 Share Posted May 28, 2013 OK, this should work now. rabbit.bas Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 28, 2013 Author Share Posted May 28, 2013 Wow! That was a smart piece of code! You truly are a master! That really was an elegant solution! Now, if I wanted multiple player1's to appear how would I fix that? Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted May 28, 2013 Share Posted May 28, 2013 (edited) Well, one solution would be to use the multisprite kernel, but the only drawbacks are you can't use any other kernel (i.e. player1colors), and the playfield has to be symmetrical, which, for your program (at least so far) wouldn't be a problem. But another drawback to using the mutlisprite kernel is that players0-5y are reversed, so 0 would be the bottom and approx. 90 would be the top. And, there is the DPC+ kernel which allows up to 9 players, but I haven't played around with it yet. If you're OK with flickering, you wouldn't have to use the multisprite kernel, but having 3 extra player1s would result in a Pac-Man for VCS-ghost-like scenario, so maybe like two or three enemies would be OK. Edited May 28, 2013 by atari2600land Quote Link to comment Share on other sites More sharing options...
bogax Posted May 28, 2013 Share Posted May 28, 2013 (edited) I see atari2600land beat me to it but here's mine (haven't looked atatari2600land's yet) 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 v1x = u x=50 y=56 v1x = -1 player1x = 137 player1y = 32 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 = player1x + v1x if player1x > 16 then skip player1x=137 a = rand & 1 if a then player1y = 32 else player1y = 56 skip 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 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 @Atari2600Land Flickering is alright. But the multikernel might be a must for me, since I'm going to add fruits that the player has to collect to get points. I don't really get how the multikernel works. Do I have to download a file and add it for it to work, or? And how does multi flickering sprites work? @bogax Thank you very much =) It's great to see different solutions! I've learned plenty from you guys! Thanks for being so patient with me. Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted May 28, 2013 Share Posted May 28, 2013 the multisprite kernel should already be in the bB package you got. If you go the multisprite kernel way, then you don't have to worry about extra code for changing the player1's x and y positions since essentially the multisprite kernel does that for you. To use it, just put "set kernel multisprite" at the beginning of your program. This enables you to use the multisprite kernel, which grants you players 2-5. But like I said before, the y positions are reversed with this kernel (don't ask me, I don't know why.) From my use with this, player0y=0 is at the bottom, while player0y=88 or so should be the top. You'd then have to play around a bit to find the new positions for the sprites. Also, I should note that you can have sprites 2-5 be different colors, but in order to color player1, you use _COLUP1 (note the underscore before COLUP, and again, don't ask me why.) 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 added "set kernel multisprite". My gamefield looks really strange? Edited May 28, 2013 by Rabbit 2600 Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted May 28, 2013 Share Posted May 28, 2013 I forgot, you might want to add "const pfheight=7" at the beginning (after set kernel multisprite) to make it look like the version before. Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 28, 2013 Author Share Posted May 28, 2013 Hm, tried it. A purple curtain effect started, and then everything went black with the "const pfheight=7" XD Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted May 28, 2013 Share Posted May 28, 2013 Try not adding the const before it. And player1 would be black if you didn't put the underscore before the COLUP1. Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 28, 2013 Author Share Posted May 28, 2013 I did put the const after the kernel. I tried adding it literally after the kernel, both on the same line, and having it under the kernel. Under the kernel the curtain effect happens. But when they are on the same line I get no change at all, just the same strange background. Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted May 28, 2013 Share Posted May 28, 2013 I meant add "pfheight=7", not "const pfheight=7". Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 28, 2013 Author Share Posted May 28, 2013 It works now when I took out "const". Cheers! I'm guessing adding player2 will be a snap? I'd just use the same settings for player1 but exchange the "player1"'s to "player2"'s? Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted May 28, 2013 Share Posted May 28, 2013 Yep. player2x, player2y, and COLUP2 all work with the multisprite kernel. Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 28, 2013 Author Share Posted May 28, 2013 (edited) Okay, I got player2 working! Awesome! But sometimes Player1 and Player2 overlap. Can I prevent this by setting the rand/128 to rand/32 or something so they don't come at the exact same time? Also, how do I go about scoring with player2? When I do a collision detection between player0 and 2 it does not work at all. But with player 0 and player 1 it works and I get score when touching it. However I get score from touching Player 2 as well. rabbit.bas Edited May 28, 2013 by Rabbit 2600 Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted May 28, 2013 Share Posted May 28, 2013 Since player2-5's collision detection is also for player 1, you'll have to do something like: temp1=player2x+9 if collision(player1,player0) && player0x>=player2x && player0x<temp1 && player0y=player2y then player2y=200 : b=rand/128 : score=score+1 You can use temp1 in this case because player2's x position is also changed with each drawscreen so there is no constant. Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 28, 2013 Author Share Posted May 28, 2013 Hm, I didn't understand that at all. Could you explain the code? Quote Link to comment Share on other sites More sharing options...
bogax Posted May 28, 2013 Share Posted May 28, 2013 (edited) You can use temp1 in this case because player2's x position is also changed with each drawscreen so there is no constant. the only problem with the temp variables is that bB uses them. If you don't ask bB to do anything that uses them you're safe drawscreen uses them pfread uses temp1 and temp2 it's not always obvious that you're asking bB to do something that will use them. a multiplication or division by something other than a constant that is a power of 2 uses temp1 and temp2 multiplication and division are only things I can think of just off hand that aren't obvious or might slip by (me at least) 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 Mm'kay. Very complicated. But, I added the temp1 code and nothing happened, do I have to place it somewhere special, or? Quote Link to comment Share on other sites More sharing options...
bogax Posted May 28, 2013 Share Posted May 28, 2013 (edited) Mm'kay. Very complicated. But, I added the temp1 code and nothing happened, do I have to place it somewhere special, or? player1-5 are all actually player1 if you get a player1 collision you have to test which of them it is. Edited May 28, 2013 by bogax Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted May 29, 2013 Share Posted May 29, 2013 That's what the code I posted was trying to figure out. Where player0 was to establish which clone of player1 it was (either 2, 3, 4, or 5.) In this example I will tell what it's about. z=player0x+7 if collision(player1,player0) && player0x>=player2x && z<player2x && player0y=player1y then ... So what this means is if the right most pixel of player0 is the same as or greater than the left most pixel and the left most pixel of player0 is less than the right-most pixel of player2 and they are both on the same y axis then... Quote Link to comment Share on other sites More sharing options...
bogax Posted May 29, 2013 Share Posted May 29, 2013 That's what the code I posted was trying to figure out. Where player0 was to establish which clone of player1 it was (either 2, 3, 4, or 5.) yes you didn't quite state that explicitly so I tried to. 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.