Monopoly

Chickendude's remake of the famous Monopoly board game
  • Author
  • Message
Offline
User avatar

Madskillz

Site Admin

Re: Monopoly

Post20 November 2011, 21:49

Looking good Chickendude...the 'a' is bothering me but the changes look better for sure. Seems like your progressing nicely, keep it up!
Offline
User avatar

chickendude

Staff Member

Topic Starter

Re: Monopoly

Post21 November 2011, 00:22

I kinda liked the a, but it does look out of place. I suppose i'll just switch it for something a little more normal (without the little hook at the top). Thanks for the feedback!

UPDATE: So i stayed up way too late again, but multiplayer is now up and running:
Image
Those are two separate objects on the map, player 1 is moving and player 2 is just sitting still. I just need to swap "currentPlayer" and player 2 will start moving. More work will be done tomorrow, gotta get up early and stayed up way too late again working on this :)
Attachments
Monopoly.7z
source code Nov. 20
(1.71 MiB) Downloaded 259 times
Offline
User avatar

NanoWar

Site Admin

Re: Monopoly

Post21 November 2011, 10:38

Whoa don't you use spasm #include for bitmaps? It's so much easier to edit without copy/pasting the tile data...
Also I would use more subfolders and better file names, hehe.

Why do you do "ld a,$BF ; group 7" instead of "ld a,group 7"? There goes readability. Isn't that what include files are for? No more thinking about constants, that differ for every calc model...

Instead of:
Code: Select all
chanceDeck = safeRAM4           ;0-16       SR4 HAS  66 BYTES
commChestDeck = chanceDeck+17   ;17-32
numPlayers  = commChestDeck+17  ;33

you could use my VAR-macro:
Code: Select all
.locate safeRam4 ; needs to be set once; I use safeRam1 instead

; if you define a module here like .module "monopoly"
;  all following vars get the that prefix e.g. "monopoly.chanceDeck" etc.
.nomodule ; or you choose no module (or clear the current module)
.var "chanceDeck", 17 ; variable size = 17
.var "commChestDeck", 17
.var "numPlayers" ; default is 1
.import ; includes the temp file, so you can use the variables above instantly


You can also place your player variables this way.
Attachments
m_var.z80
Variable memory allocation macros
(2.17 KiB) Downloaded 257 times
Offline
User avatar

chickendude

Staff Member

Topic Starter

Re: Monopoly

Post21 November 2011, 12:06

I've always drawn everything with CalcGS and done it that way and haven't ever really used macros for spasm. Also, i'm using saferam1 and i think part of saferam2 (i can't remember anymore) as a gbuf to store the map. I guess i can use the gbuf now as saferam. I would've just used group7, but i can't seem to find an old copy of keys.inc. Anyways, i'm pretty sure there isn't any change between the 82/3/+ series, and i think even the 86 uses the same group values. To be honest, i don't know if i use anything from ti83plus.inc, and i think the only thing from ion.inc i'm using are the saferam equates...

And the new player data needs to be organized better, currently i just threw in a few bytes above the sprite-drawing routines. Ideally, i will move all that into saferam. I'm still not sure how i want to organize everything, the players' information, properties, etc. I always say i'll go back later and fix things up, make them prettier, but usually once it works that's the last time i look at a code ;)

I'd be interested in knowing how to include bitmaps. Can you include multiple sprites in one file or is it a separate bmp for each sprite? If you feel like looking at anything else, i'd be more than happy to hear your thoughts/suggestions :) I haven't commented everything very well yet, though.

Also, what's wrong with my filenames?! :P
Offline
User avatar

NanoWar

Site Admin

Re: Monopoly

Post21 November 2011, 16:56

Commenting is key. Clean code is also much more extensible and easier to maintain. I try to program modularized, looks a bit like object oriented, you can see that in the screenshot below. Input registers of routines are in upper-case, so you can follow them through the code. Routines have input, output and destroy fields. Every module gets an own file. Routines and macros are generalized and encapsulated in files so I can reuse them in every project.

BTW: Do you want a subforum?

For bitmaps you just do "#include /folder/image.bmp" and it inserts everything into the program byte stream at the #include position. I use a shell-script to auto-include every *.bmp-file in the images folder, which produces something like:
Code: Select all
Image1: #include /images/image1.bmp
Image2: #include /images/image2.bmp

; remember commenting is key ;)
Attachments
HowICodeLegends.png
Legends set-up
(218.13 KiB) Not downloaded yet
Offline
User avatar

chickendude

Staff Member

Topic Starter

Re: Monopoly

Post22 November 2011, 01:34

Thanks. And i really do need to work on organizing my code better, though what you've got there is all basically Chinese to me, i don't even know where to start! I guess all the first parts are just the module names?

Btw, it appears that we've got our own private forum ;)
Offline
User avatar

NanoWar

Site Admin

Re: Monopoly

Post22 November 2011, 10:16

It's really easy if you look at the macro codes.

Code: Select all
.locate address ; sets an internal counter to 'address'
.module "name" ; defines the prefix to 'name'
.var "name", size ; writes a define of a variable 'name' into a temp file and increases the counter by 'size' (prefix.name = counter++)
.import ; includes the temp file
 

This just gets rid of counting the memory addresses by yourself like ;0-16 ;17-32 what I think you did.
You can also the VAR macros as enumerations if you use ".locate 0" or so.

I meant a subforum for monopoly...
Offline
User avatar

chickendude

Staff Member

Topic Starter

Re: Monopoly

Post22 November 2011, 10:50

Oy! I completely missed that part, i was just thinking how it's basically the two of us posting here. Sure, if you don't mind. I hadn't really planned on turning this into a project, i just got hooked into it i suppose once i started coding a few lines and now can't stop! Thanks.
Offline
User avatar

NanoWar

Site Admin

Re: Monopoly

Post22 November 2011, 16:22

chickendude wrote:...once i started coding a few lines and now can't stop!

I do know that feeling ;) .

Heh cool, didn't know you entered zContest! ^^

Made you a forum!
Offline
User avatar

chickendude

Staff Member

Topic Starter

Re: Monopoly

Post22 November 2011, 23:26

Wow, thanks, my own subforum! Now i can add one more to the list of unfinished projects :D
Offline
User avatar

NanoWar

Site Admin

Re: Monopoly

Post25 November 2011, 16:09

And let's not talk about the list with all the unstarted projects!

[Edit: Btw, did anyone try the bump feature yet?]
Offline
User avatar

chickendude

Staff Member

Topic Starter

Re: Monopoly

Post25 November 2011, 16:19

I take it you've just tried it? :D

Buying properties:
Image
Offline
User avatar

chickendude

Staff Member

Topic Starter

Re: Monopoly

Post26 November 2011, 20:24

Can anyone think of a good way to link strings? Basically, i'd like to do something like this:
"This property costs: $",$FA,5,". Do you want to buy it?",0
$FA just being an example, basically a byte to let the text handler know that the next byte is a databyte, not a letter. I think the stack could maybe be used for this:
Code: Select all
ld hl,-1
push hl
ld hl,string_to_draw
push hl

then pop hl to get the next string. When i reach a $FA byte, push hl+2 (skip $FA and $05) and load the address of the new string into hl and continue processing until hl pops $FFFF (ie inc hl / ret z) or maybe $0000 (ld a,l / cp h / ret z).

Right now the text drawing sections look really ugly, and there'll be several points where i'll need to display the same figures (player's money, property price, etc.), and rather than display each string separately it'd be easier to just load it all into one string and display that.

(EDIT: Totally just put on the FFVII soundtrack while transcribing the alphabet into .bmps.. this music makes me want to cry! Such strong memories... Don't even ask me to listen to the Legend of Legaia OST, i don't think i could handle that.)
Offline
User avatar

Madskillz

Site Admin

Re: Monopoly

Post27 November 2011, 03:13

Wow Nano I like that modular programming....I never wrote my code like that but perhaps I'll have to start if I get back into z80.
I like the sprites chickendude, but I got a question. Do you have it implemented for when two pieces are on the same property yet or is that incoming?
Offline
User avatar

chickendude

Staff Member

Topic Starter

Re: Monopoly

Post27 November 2011, 03:42

What do you mean? Currently, the current player is drawn last (aka on top). If two or more players who aren't currently playing on the same square, they're just drawn according to their player id, either from low to high or high to low, don't remember which. Does something special happen when two players are on the same square? Or are you just talking about how the bottom sprite(s) is(are) covered up?

I've spent pretty much all day trying to reorganize (the structure) of my text routine to make it a little more flexible, basically so that it's easier to add new characters later if i need to (what prompted this all was that i wanted to add in a colon character). After a lot of agony, the routine is ready to use, unfortunately a lot of my strings are broken now because i added a few new characters (colon, semicolon, parentheses, and implemented the checkbox type thing in there as well). Tomorrow i'll probably rerun the broken strings through my php script and figure out how an efficient way to link strings together. Monopoly will definitely not be finished by the 30th, but i think i've made a lot of progress the past three weeks (especially since my programming has been limited mostly to the weekends and Fridays), and Monopoly seems to be more complete than it ever was before. The only thing really missing now that the old version had is the stats/menu browsing routine, the pretty dice rolling routine KRoot had written, and functional Chance cards. But i've already written "giveMoney" and "takeMoney" routines which do all the work for me.

So my priority after the text routine will be the stats menu, as it'd be incredibly handy to debug all the property stuff. But none of that is really too difficult, so... we'll see.
Offline
User avatar

chickendude

Staff Member

Topic Starter

Re: Monopoly

Post27 November 2011, 16:04

Alright, i spent all night last night and another couple hours today trying to make the text routine a little more flexible, converting the alphabet to .bmp, making it easier to add/remove characters, and making things a lot easier to upgrade. For example, here's the landed on property text:
Code: Select all
textLandedOn:
;You've landed on:
;[property]
.db _Y,_o,_u,_APOSTROPHE,_v,_e,T_SPACE,_l,_a,_n,_d,_e,_d,T_SPACE,_o,_n,_COLON,T_NEWLINE
.db T_INSERT,I_PROPERTY,T_NEWLINE,T_EOS
Still a little rough on the eyes, but now as everything is equated if i want to make changes in the future all the old converted text will still work. Right now a lot of the text is broken because i haven't converted it over yet. You can also see that the text routine now handles certain things (with the T_INSERT), like displaying the name of the current property you are on (I_PROPERTY, I for INSERT). You can also insert the amount of cash the current player has, and a few other things are coming. A lot of hand-typing everything, but at last everything is working again!

Re: Monopoly

Post27 November 2011, 16:14

I don't understand what's the improvement. Your text routines was already working, why do you convert it into bmp???
Offline
User avatar

chickendude

Staff Member

Topic Starter

Re: Monopoly

Post27 November 2011, 16:34

The reason for that was that i realized i wanted to add a new character (a colon ":"), but to do that i'd have to hardcode it in and change a large portion of my strings. This way, my text routine is a lot more dynamic. Also, if i decide i don't like how a letter looks, i can just change the bitmap and not have to deal with hexcodes. Basically, it was just to reorganize everything to make it easier to use later on or for other people who might want to use my code in other projects. Besides, now everything is a lot more automated and the strings and code look nicer!
Offline
User avatar

NanoWar

Site Admin

Re: Monopoly

Post27 November 2011, 20:01

Honestly, this .db _Y,_o,_u,_APOSTROPHE,_v,_e,T_SPACE,_l,_a,_n,_d,_e,_d,T_SPACE,_o,_n,_COLON,T_NEWLINE does not look nice at all :( . It seems like you did it in a roundabout way.
Offline
User avatar

Madskillz

Site Admin

Re: Monopoly

Post28 November 2011, 02:51

Yeah that was what I was asking Chickendude. I wasn't sure if you just covered them up or what.
Offline
User avatar

chickendude

Staff Member

Topic Starter

Re: Monopoly

Post28 November 2011, 12:02

NanoWar, i can't think of another way to do it. I could try coding it into Spasm, but i'm not sure where to code it or how to get it compiled. I guess just downloading a couple files that i'm missing? I'll have to look at that another day, though.
Offline
User avatar

chickendude

Staff Member

Topic Starter

Re: Monopoly

Post01 January 2012, 00:41

So who knows how long it's been since someone's posted here, i haven't really done anything since i last updated, at least not until today. Today i started working on the text engine (againnn, ugh), trying to make it able to display larger amounts of text and be able to scroll. I really liked the old way i had, but it simply won't work with the properties menu when someone has a lot of properties (at least not how i want the menu to be arranged). I thought about arranging the properties by color so that you would work with each different color separately, but in the end i'd just rather have one long list of all your properties. After this it'll be finishing the other tiles (railroad and utilities).
Offline
User avatar

chickendude

Staff Member

Topic Starter

Re: Monopoly

Post02 January 2012, 18:25

Ughh, i've been looking at the same 20 lines of code for the past 4 hours and have no clue what's going wrong. Before, i really liked my text routine, but now it's becoming really ugly and bloated (not to mention that it's currently broken), just because of the properties menu. If i ever get this fixed i will definitely be taking a little break off from Monopoly!

UPDATE: Wow, i wish i'd posted this 3 or 4 hours ago. I post this and literally ten seconds later it came to me, i wasn't handling newlines written in the text (.db "hello",newline,"next line",0) correctly, only when textwrapping. Anyway, it still looks really ugly... Now let's see if i can finish the new text system...
Offline
User avatar

NanoWar

Site Admin

Re: Monopoly

Post04 January 2012, 19:53

Wow your text routine screws you at regular intervals... good luck.

Also kind of cool that you work in this during the holidays. Seems you have the monopole on that. Ha.
Offline
User avatar

chickendude

Staff Member

Topic Starter

Re: Monopoly

Post04 January 2012, 23:11

Yep. In Monopoly, as there really isn't a lot going on, the majority of the code is in the text routine. Most of the game you spend in the menus! What was giving me a big headache was that my routine only supported about 11 lines of text (however many fit inside gbuf, using it as a buffer 10 bytes wide instead of 12). Now i've got it so that it extracts all the strings before drawing them and saves it to (yet another) buffer and stores the position of all the new lines in that new string. Currently it'll display all the properties you own, but i need to fill in the parts for when you have, say 23 properties (and the other person would have what... like 5? :P).

And my real inspiration came from the lack updates on the site :D New Year's? There's always next year...
PreviousNext

Return to Monopoly

Who is online

Users browsing this forum: No registered users and 1 guest

cron