jbs30000 Posted October 24, 2011 Share Posted October 24, 2011 I have re-started my Mario game using the DPC+ kernel. This time I'm off to a great start and the code to dim my variables is a lot neater, cleaner, and easier to read than before. Because of the limited amount of variables I used DEF a lot, but ran into the 50 DEF limit. So I've come up with a new way to set values, but I'm curious if there's an even better way. First, a sample of how I was doing it: def Make_Mario_Small=a{0}=0 def Make_Mario_Large=a{0}=1 def Mario_is_Small=!a{0} rem ******************** def Make_Mario_Normal=a{1}=0 def Make_Mario_FirePowered=a{1}=1 def Mario_is_Normal=!a{1} So, to make Mario large, all I'd have to type is Make_Mario_Large. To check Mario's size all I'd have to type is if Mario_is_Small then x else y. How I'm redoing it is like this: macro Poke {1}={1}&{2}|{3} end def Setup=callmacro Poke rem ******************** rem * Mario variables. * rem ******************** dim Mario=a rem ******************** const _Size=%11111110 const _Small=0 const _Large=1 rem ******************** const _Power=%11111101 const _None=0 const _Fire=2 So here, to make Mario large I go Setup Mario _Size _Large. To see if he's large I go if Mario&!_Size=_Large then x. So, this works, but is there an even better way to do this? Quote Link to comment Share on other sites More sharing options...
+Gemintronic Posted October 25, 2011 Share Posted October 25, 2011 Forgive me if this seems like trolling, but, you may be over-engineering this. You might consider allocating a variable for Mario that is used exclusively for boolean values: DIM mariostats = a Each bit could represent a logical value such as: mariostats{0} could be 0 if Mario is small and 1 if mario is large So, if you hit a Goomba the logic would be concise: if mariostats{0} then [do what you need to do to make him small] You would still need to manually keep track of which bit represents what state but I bet the assembly output would be simpler.. Quote Link to comment Share on other sites More sharing options...
jbs30000 Posted October 25, 2011 Author Share Posted October 25, 2011 The way it will work is that Mario starts out with a{0}=0. When he gets a mushroom then a{0}=1. I want to express that in English so that the program is easy to read. So far I'm just going with the consts since I read on Random Terrain's board that you can have 500 of them. Quote Link to comment Share on other sites More sharing options...
jbs30000 Posted October 26, 2011 Author Share Posted October 26, 2011 OK, I settled on using single defs for each attribute. def True=1 def False=0 def Mario_is_Large=a{0} def Mario_has_FirePower=a{1} My main goal is to have other people (as well as I) be able to look at the code, and with little to no REM statements easily know what's going on because there's going to be a lot of code and it could get confusing easily if it's not immediately clear what the code does. Mario_is_Large=False isn't the best way to say that Mario is small, but it works. 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.