+Gemintronic Posted March 15, 2014 Share Posted March 15, 2014 So, in my latest game I'm having trouble updating the 3rd and 4th digit in the score. I'm using it as an inventory bar. score = 0 if has_sword then score = score + 100000 if has_shield then score = score + 20000 if has_ring then score = score + 3000 if has_food then score = score + 400 if has_potion then score = score + 50 if has_scroll then score = score + 6 When I attempt to update it this way it just doesn't go. If I later go "score = 3400" then it appears to work correctly. Is this the wrong way to try an inventory bar using the score? Is there a better way? atarowg11.bas Quote Link to comment Share on other sites More sharing options...
GroovyBee Posted March 15, 2014 Share Posted March 15, 2014 Can you attach the *.lst file (after its been through the assembler). Quote Link to comment Share on other sites More sharing options...
+Gemintronic Posted March 15, 2014 Author Share Posted March 15, 2014 Can you attach the *.lst file (after its been through the assembler). Not sure what an .lst file is or how to produce it. Here is the .asm file.. is that helpful? atarowg11.bas.asm Quote Link to comment Share on other sites More sharing options...
GroovyBee Posted March 15, 2014 Share Posted March 15, 2014 BCD mode seems to enabled and disabled around the adds to the score so I'm not quite sure what the problem is ast the moment. 1 Quote Link to comment Share on other sites More sharing options...
Omegamatrix Posted March 15, 2014 Share Posted March 15, 2014 What is happening in this game? Am I supposed to find items/treasure chests? Am I suppose to fight that creature and he drops something? I ran around the game for a long time, and tried fighting the creature with the firebutton, but nothing happened. I did this with a breakpoint in Stella at your score code, and found that you never reach there. So I think you got some logic errors that is not letting you even get to that code. Quote Link to comment Share on other sites More sharing options...
+Gemintronic Posted March 15, 2014 Author Share Posted March 15, 2014 What is happening in this game? Am I supposed to find items/treasure chests? Am I suppose to fight that creature and he drops something? I ran around the game for a long time, and tried fighting the creature with the firebutton, but nothing happened. I did this with a breakpoint in Stella at your score code, and found that you never reach there. So I think you got some logic errors that is not letting you even get to that code. Eventually you find rooms with treasure chests. The treasure chest will have a random item 1-6 that gets added to your inventory bar. When testing I just hit F2/reset until a chest appeared nearby. Thanks for taking a look This is my attempt at a 7 day Rogue-like. It's pretty far from finished. All you can do is go down stairs and nab items from an occasional treasure chest. I kind of underestimated the potential for roadblocks like not being able to manipulate the score correctly. Quote Link to comment Share on other sites More sharing options...
RevEng Posted March 15, 2014 Share Posted March 15, 2014 (edited) You can't directly assign a variable to the score, so at the very least, this line is messing up the score... score = enemyhp ...if you really want to do that, use score=score+enemyhp. But be sure enemyhp is a BCD value. Edited March 15, 2014 by RevEng Quote Link to comment Share on other sites More sharing options...
bogax Posted March 15, 2014 Share Posted March 15, 2014 (edited) rand&5 will produce one of four values 0,1,4 or 5 you'll never see 2 or 3 this should work temp1 = rand/2 : temp1 = (temp1/2 + temp1)/32 Edited March 15, 2014 by bogax 2 Quote Link to comment Share on other sites More sharing options...
+Gemintronic Posted March 15, 2014 Author Share Posted March 15, 2014 rand&5 will produce one of four values 0,1,4 or 5 you'll never see 2 or 3 this should work temp1 = rand/2 : temp1 = (temp1/2 + temp1)/32 YOU. GUYS. ROCK! This was the solution. I'm very, very grateful for the posts here. Even the people who didn't post and just simply considered my quandary like Random Terrain and Andrew Davie. Thanks 'yall UPDATE: Is this never-see-a-2-or-3 a symptom of using foo&5? Or, is it something in how rand generates its results? Quote Link to comment Share on other sites More sharing options...
RevEng Posted March 16, 2014 Share Posted March 16, 2014 (edited) It's a symptom of using foo&5. The & trick to reduce the number range only properly works with 1, 3, 7, 15, 31, 63, 127. (i.e. powers of two, less one) See the "did you know" box in the random number section of RT's site for more info. Edited March 17, 2014 by RevEng 2 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.