+atari2600land Posted June 23, 2006 Share Posted June 23, 2006 (edited) What do I need to add in this code to make the missiles move by themselves? Also, how do I make player1 shoot missiles all by itself? 1 set smartbranching on 10 player0: %0111110 %1111111 %1111111 %1111111 %0111110 end 20 player1: %01000010 %00100100 %01000010 %00100100 %00111100 %00111100 end 40 x=80 : y=20 : a = 60 : b =60 : c=x+4 : d=y : scorecolor = 30 : missile0height=4 45 COLUP0 = 14 : COLUP1 = 30 : COLUBK = 0 : COLUPF = 64 50 player0x=x : player0y=y : player1x= a : player1y = b : missile0x = c : missile0y= d 60 pfhline 0 5 11 on 62 pfhline 21 5 31 on 70 if joy0left then x=x-1 : c=c-1 if x<31 then x=31 80 if joy0right then x=x+1 : c=c+1 if x>150 then x=150 90 if joy0fire then goto 100 95 goto 110 100 d=d+1 if d>70 then d=20 110 a=a-1 if a=31 then a=150 195 drawscreen 200 goto 45 Edited June 24, 2006 by atari2600land Quote Link to comment https://forums.atariage.com/topic/89629-shooting-game-question/ Share on other sites More sharing options...
SeaGtGruff Posted June 24, 2006 Share Posted June 24, 2006 What do I need to add in this code to make the missiles move by themselves? Are you trying to do something like this? 1 set smartbranching on dim missile0_fired = z 10 player0: %0111110 %1111111 %1111111 %1111111 %0111110 end 20 player1: %01000010 %00100100 %01000010 %00100100 %00111100 %00111100 end 40 x = 80 y = 20 a = 60 b = 60 c = x + 4 d = y - 1 scorecolor = 30 missile0_fired = 0 45 COLUP0 = 14 COLUP1 = 30 COLUBK = 0 COLUPF = 64 50 player0x = x player0y = y player1x = a player1y = b if missile0_fired = 0 then missile0height = 0 if missile0_fired = 1 then missile0height = 4 missile0x = c missile0y = d 60 pfhline 0 5 11 on 62 pfhline 21 5 31 on 70 if joy0left then x = x - 1 : if x < 31 then x = 31 80 if joy0right then x = x + 1 : if x > 150 then x = 150 85 if missile0_fired = 0 then c = x + 4 : d = y - 1 90 if joy0fire then missile0_fired = 1 100 if missile0_fired = 1 then d = d + 1 105 if d > 70 then missile0_fired = 0 110 a = a - 1 120 if a = 31 then a = 150 195 drawscreen 200 goto 45 Also, how do I make player1 shoot missiles all by itself? I didn't want to add that yet, because I'm not sure I understand what you want it to do-- fire over and over again continuously, or fire when it gets to a certain horizontal location, or fire when it's within a certain horizontal distance to player0, etc. Okay, I lied. The truth is, I didn't even see that part of your question until just now, when I was posting the updated version of your code. But I also don't know what you want exactly. Anyway, let me know and I'll add some more code. Michael Rideout Shooting_game_question_1.bas Shooting_game_question_1.bas.bin Quote Link to comment https://forums.atariage.com/topic/89629-shooting-game-question/#findComment-1089065 Share on other sites More sharing options...
+atari2600land Posted June 24, 2006 Author Share Posted June 24, 2006 Yes, that's exactly what I'm trying to do! Also, I want player1 shooting when it's within a certain horizontal distance to player0. Quote Link to comment https://forums.atariage.com/topic/89629-shooting-game-question/#findComment-1089080 Share on other sites More sharing options...
SeaGtGruff Posted June 24, 2006 Share Posted June 24, 2006 Yes, that's exactly what I'm trying to do! Also, I want player1 shooting when it's within a certain horizontal distance to player0. Okay, this adds player1 firing missile1 at player0. I took out all unnecessary line numbers because it wasn't compiling correctly, and removing the line numbers was an act of desparation. Since doing do fixed the compile error, I presume that I had accidentally used a duplicate line number somewhere. You can line numbers back to it if you prefer. To change the distance between player0 and player1 which will trigger player1 to fire at player0, just change "distance = 5" to some other value, but it should be greater than 0. Michael Rideout Shooting_game_question_2.bas Shooting_game_question_2.bas.bin Quote Link to comment https://forums.atariage.com/topic/89629-shooting-game-question/#findComment-1089120 Share on other sites More sharing options...
+atari2600land Posted June 24, 2006 Author Share Posted June 24, 2006 (edited) One more change if you'd be so kind, and that's it (I promise.) I changed around some sprites and got rid of the red lines and changed those pfpixels to life showers. I made l be the life counter, and what I want is the pfpixels to decrease with each life lost (3 lives), and for the ship (player0) to stay where it is once it's been hit. Also, make my life counter work (make the score stay where it was instead of going back to 0 when hit once & twice.) Shooting_game_question_2a.bas Edited June 24, 2006 by atari2600land Quote Link to comment https://forums.atariage.com/topic/89629-shooting-game-question/#findComment-1089142 Share on other sites More sharing options...
SeaGtGruff Posted June 24, 2006 Share Posted June 24, 2006 One more change if you'd be so kind, and that's it (I promise.) I changed around some sprites and got rid of the red lines and changed those pfpixels to life showers. I made l be the life counter, and what I want is the pfpixels to decrease with each life lost (3 lives), and for the ship (player0) to stay where it is once it's been hit. Also, make my life counter work (make the score stay where it was instead of going back to 0 when hit once & twice.) In adding or fixing the things you requested, I ended up revamping the code a bit, as follows: I replaced all of the 1-letter bB variables with more self-explanatory variable names, and I revised which 1-letter variables are being used (e.g., the x position of the ship is no longer given by variable x). The advantage of using more self-explanatory variable names is that it makes the code easier to understand when you're reading it (i.e., instead of the reader saying "x = x + 1? What's that do?", a statement like "ship_x = ship_x + 1" is easy to understand). And by assigning (dimming) each of the variables in alphabetical sequence (i.e., first a, then b, then c, etc.), it's easier to see how many of bB's variables are still available (e.g., "Now I want to add another variable, and I see that the last variable I dimmed was m, so this one will be dim new_variable = n"). I also changed some of the variable names I'd already dimmed so they would be more self-explanatory(e.g., m1_fired is now alien_missile_fired). I took the longer if...then statements and changed them to use gosubs, so the statements don't trail off the right side of the editor's screen (at least, on the editor I'm using, with the font settings and window size, etc.). I spaced the lives-remaining indicators apart, so it's easier to see how many of them there are. I added a "GAME OVER" screen for when the game ends. I rearranged the order of some of the statements, because I was having various quirky problems, and some of them turned out to be caused by the order that things were being done (e.g., the score was increasing by 2 or even 3 points at a time when the alien was hit). Anyway, the actual game play is otherwise as you'd had it, or as you requested it. But do you really want the player's ship to become immovable after it's hit? That means the alien can hit the ship two more times without the player being able to do anything about it, and then the game is over. Here are a few suggestions I'd like to offer, as an alternative: When the ship is hit the first time, it could damage the ship a bit so that it moves slower (i.e., at half of its normal speed), rather than destroying the ship completely and ending one of the lives. When the ship is hit the second time, it could damage the ship even more, so that it moves slower still (i.e., at one-fourth speed, basically a crawl), but still isn't destroyed yet. When the ship is hit the third time, it could totally damage the ship's engines (i.e., the ship can't move at all), but the ship still isn't destroyed yet. When the ship is hit the fourth time, then it's destroyed and the player loses a life. If the player has any lives remaining, then of course the new ship starts out at full capacity. Likewise, you could do the same sort of thing with the alien. Hit it once, it moves at half-speed. Hit it again, it moves at quarter-speed. Hit a third time, it can't move. Hit a fourth time, it's destroyed and a new alien appears. Another idea, for when the ship has become immobile, is to let the player aim the ship's missiles so the ship can shoot toward the alien while it's approaching, or while it's moving away (i.e., if the ship is immobile, then firing a missile while the joystick is pushed left or right will make the missile fall in that direction). Or you could even do that while the ship is still mobile (i.e., the ship can always fire the missile in one of three or five directions-- straight down, towards the right, towards the left, and maybe also towards the left or right just a little bit). What do you think? Michael Rideout Shooting_game_question_2b.bas Shooting_game_question_2b.bas.bin Quote Link to comment https://forums.atariage.com/topic/89629-shooting-game-question/#findComment-1089412 Share on other sites More sharing options...
+atari2600land Posted June 24, 2006 Author Share Posted June 24, 2006 I wanted the ship to keep moving after it's been hit. You'll have to excuse my crappy programming skills, but that's what I wanted accomplished. Likewise, you could do the same sort of thing with the alien. Hit it once, it moves at half-speed. Hit it again, it moves at quarter-speed. Hit a third time, it can't move. Hit a fourth time, it's destroyed and a new alien appears. That would be cool. To do that, I'd like for one point to score after the alien disappears. Quote Link to comment https://forums.atariage.com/topic/89629-shooting-game-question/#findComment-1089444 Share on other sites More sharing options...
SeaGtGruff Posted June 25, 2006 Share Posted June 25, 2006 I wanted the ship to keep moving after it's been hit. You'll have to excuse my crappy programming skills, but that's what I wanted accomplished. Okay, I put it back to the way it was. I guess I misunderstood what you meant by "stay where it is" when you said... what I want is ... for the ship (player0) to stay where it is once it's been hit. Likewise, you could do the same sort of thing with the alien. Hit it once, it moves at half-speed. Hit it again, it moves at quarter-speed. Hit a third time, it can't move. Hit a fourth time, it's destroyed and a new alien appears. That would be cool. To do that, I'd like for one point to score after the alien disappears. Okey dokey! Since the alien's movement is connected to the Atari's screen rate-- i.e., it moves one pixel each time the screen is drawn, or roughly 60 times a second-- the way to make it move slower is to move it one pixel every two screens, or one pixel every three screens, etc. So you'd need to add a variable to be a frame counter, and a variable to count how many times the alien has been hit, which I've added for you. The only semi-tricky part is where it checks frame{0}, or the lowest bit (bit 0) of the frame variable. If bit 0 is set, then it means that frame is an odd number-- in this case, 1 or 3, since frame is always from 0 to 3. Michael Rideout Shooting_game_question_2c.bas Shooting_game_question_2c.bas.bin Quote Link to comment https://forums.atariage.com/topic/89629-shooting-game-question/#findComment-1089705 Share on other sites More sharing options...
+atari2600land Posted June 25, 2006 Author Share Posted June 25, 2006 Thanks a ton! You have really helped a lot and have done magnificent work for my game. You may go back to living your life now. Quote Link to comment https://forums.atariage.com/topic/89629-shooting-game-question/#findComment-1089706 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.