Rabbit 2600 Posted May 29, 2013 Share Posted May 29, 2013 I just discovered the wonders of NUSIZ1 = 33. I love that it gets me multiple clones on the screen. There is however 1 thing I'm having issues with: How do I make it so that when 1 of the clones is hit by the missile only that one gets destroyed instead of all of them? Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted May 29, 2013 Share Posted May 29, 2013 (edited) You need to figure out which copy was hit, then update NUSIZ1 and possibly the X position. based on this: D2 D1 D0 Description 0 0 0 X one copy 0 0 1 X X two copies - close 0 1 0 X X two copies - med 0 1 1 X X X three copies - close If you start out with NUSIZ1 = $x3 (x = any hex value) then you're showing 3 copies close. If you hit one of them then you have 3 possible things to do: 1st copy hit: change NUSIZ1 to $x1 (for two copies close) add 16 to X position 2nd copy hit: change NUSIZ1 to $x2 (for two copies medium) X not changed 3rd copy hit: change NUSIZ1 to $x1 (for two copies close) X not changed. To figure out which one was hit, do some comparisons. If you're using missile0 then do something like: temp = missile0_x - player1_x if temp < 8 then 1st copy hit else if temp < 24 then 2nd copy hit else 3rd copy hit Edited May 29, 2013 by SpiceWare Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 29, 2013 Author Share Posted May 29, 2013 Ahh, thank you for explaining! I think I understand. I'm off to test things out then report my progress, or lack of progress, haha =) Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 29, 2013 Author Share Posted May 29, 2013 Hm, I understand the workings, but not how to write it out. I can't get it to work. Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted May 30, 2013 Share Posted May 30, 2013 (edited) Hm, I understand the workings, but not how to write it out. I can't get it to work. Here's a simple example I threw together. It's messy-- I didn't try to consolidate RAM space by dimming bit variables, for example, and I'm sure someone can find ways to improve the logic-- but it works. Edit: Minor correction to the player1_1st_copy_hit routine. I'm attaching the updated files. simple_shooter_example.bas simple_shooter_example.bas.bin Edited May 30, 2013 by SeaGtGruff Quote Link to comment Share on other sites More sharing options...
bogax Posted May 30, 2013 Share Posted May 30, 2013 (edited) Here's another one x3.bas edit cleaned it up a little Edited May 30, 2013 by bogax Quote Link to comment Share on other sites More sharing options...
bogax Posted May 30, 2013 Share Posted May 30, 2013 Here's a simple example I threw together. Wouldn't compile for me. Doesn't like the if statement on line 96 if player1x + temp1 > 154 then player1x = 153 - temp1 : player1_motion = 255 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted May 30, 2013 Share Posted May 30, 2013 Wouldn't compile for me. Doesn't like the if statement on line 96 if player1x + temp1 > 154 then player1x = 153 - temp1 : player1_motion = 255 Some versions of bB won't let you do math in an if-then. You have to do something like this: temp5 = player1x + temp1 if temp5 > 154 then player1x = 153 - temp1 : player1_motion = 255 Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted May 30, 2013 Author Share Posted May 30, 2013 Cheers for all the examples =) Hopefully I'll get my head around how this works =) Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted May 30, 2013 Share Posted May 30, 2013 Wouldn't compile for me. Doesn't like the if statement on line 96 I seem to have all kinds of trouble getting if statements to compile sometimes-- and I swear a lot of the time the logic is the same as what used to work in earlier versions of bB. Usually when I have a problem it seems like the compiler is trying to interpret a logical combination as a complex math statement. That's why several of the ifs in my example program use nested ifs rather than &s. And IIRC the compiler has trouble handling elses the way you'd expect, like "if a then b else c : d : e"-- my expectation is that "c : d : e" would all be part of the else, but instead only c is the else and "d : e" execute regardless, as though there were an endif after c. I guess that's fair (as in "turnabout is fair play") if you can't do something like "if a then b : c : d else e." Yet the compiler usually has no trouble handling "if a then b : c : d" without an else. It would be awesome to eventually have true "if-then-else-endif" statements that let us use multiline thens and elses-- it would help simplify a lot of cases where you end up having to invert the if and use a goto to jump over what would have been a lengthy then. As far as why that particular line wouldn't compile for you-- I don't know. Sometimes a statement won't compile in one updated version, but then I try a slightly different updated version and it works. I get a headache trying to juggle around all the minor updates. It's gotten to be a mess. Quote Link to comment Share on other sites More sharing options...
bogax Posted May 30, 2013 Share Posted May 30, 2013 Just for the hell of it here the collision determination is done by looping through the three copies. Probably not worth the bother but it saves 10 bytes x3_cloop.bas Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted May 30, 2013 Share Posted May 30, 2013 (edited) Probably not worth the bother but it saves 10 bytes it's totally worth the bother - saving memory, even "just" 10 bytes for a single routine, is a crucial part of 2600 development. I spend a lot of time reviewing my code to find space savings. One way is to overlap data, you'll find 582 instances of "overlap" in the source for Space Rocks - that's over 1/2 K saved in a 32K game. Most of those overlaps are single bytes, such as these 4 bytes saved by overlapping the UFO data: UFO_Solid0: .byte zz___X____ ; 0 .byte zz__X_X___ ; 1 .byte zz__XXX___ ; 2 .byte zz_X___X__ ; 3 .byte zz__XXX___ ; 4 ; .byte zz___X____ ; 5 overlap with 1 UFO_Solid0Height = * - UFO_Solid0 + 1 UFO_Solid1: .byte zz___X____ ; 0 .byte zz__X_X___ ; 1 .byte zz__XXX___ ; 2 .byte zz_X__XX__ ; 3 .byte zz__XXX___ ; 4 ; .byte zz___X____ ; 5 overlap with 2 UFO_Solid1Height = * - UFO_Solid1 + 1 UFO_Solid2: .byte zz___X____ ; 0 .byte zz__X_X___ ; 1 .byte zz__XXX___ ; 2 .byte zz_X_XXX__ ; 3 .byte zz__XXX___ ; 4 ; .byte zz___X____ ; 5 overlap with 3 UFO_Solid2Height = * - UFO_Solid2 + 1 UFO_Solid3: .byte zz___X____ ; 0 .byte zz__X_X___ ; 1 .byte zz__XXX___ ; 2 .byte zz_XXX_X__ ; 3 .byte zz__XXX___ ; 4 ; .byte zz___X____ ; 5 overlap with 4 UFO_Solid3Height = * - UFO_Solid3 + 1 UFO_Solid4: .byte zz___X____ ; 0 .byte zz__X_X___ ; 1 .byte zz__XXX___ ; 2 .byte zz_XX__X__ ; 3 .byte zz__XXX___ ; 4 .byte zz___X____ ; 5 UFO_Solid4Height = * - UFO_Solid4 though some are larger such as these 8 bytes saved in the large asteroid HMOVE shift data: .byte HMOVE_0 | 0 .byte HMOVE_0 | 0 ; .byte HMOVE_R1 | 1 ; overlap with A20 ; .byte HMOVE_0 | 1 ; overlap with A20 ; .byte HMOVE_L1 | 0 ; overlap with A20 ; .byte HMOVE_R1 | 1 ; overlap with A20 ; .byte HMOVE_0 | 1 ; overlap with A20 ; .byte HMOVE_0 | 1 ; overlap with A20 ; .byte HMOVE_L1 | 0 ; overlap with A20 ; .byte HMOVE_0 | 0 ; overlap with A20 Shift_LargeAsteroid_A20: ; .byte HMOVE_0 | 0 .byte HMOVE_R1 | 1 .byte HMOVE_0 | 1 .byte HMOVE_L1 | 0 .byte HMOVE_R1 | 1 .byte HMOVE_0 | 1 .byte HMOVE_0 | 1 .byte HMOVE_L1 | 0 .byte HMOVE_0 | 0 .byte HMOVE_0 | 0 .byte HMOVE_0 | 0 .byte HMOVE_0 | 0 Edited May 30, 2013 by SpiceWare 1 Quote Link to comment Share on other sites More sharing options...
bogax Posted May 30, 2013 Share Posted May 30, 2013 it's totally worth the bother - saving memory, even "just" 10 bytes for a single routine, is a crucial part of 2600 development. oh, well then here's one that shaves another 3 bytes x3_cloop2.bas 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.