Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: SpiroH on October 02, 2012, 09:19:18 am

Title: nMah - Mahjong clone for TI-Nspire
Post by: SpiroH on October 02, 2012, 09:19:18 am
Hi, this time i'm presenting a new SDL port of a clone of the world famous classic board game: 'Mahjong solitaire' http://en.wikipedia.org/wiki/Mahjong_solitaire.
(http://imageshack.us/a/img844/9872/3nmahtiles1.png)      (http://imageshack.us/a/img688/3238/4nmahtilesback.png)
The original game is this one initially developed for linux: http://www.linuxmotors.com/sdllopan/ and called 'sdllopan' by Dave Ashley in 1999. See more on his Linux Zone: http://www.linuxmotors.com/.

Btw: i've also ported some time ago the sdl 'fire demo' from the same author, which you can find here: http://www.omnimaga.org/index.php?PHPSESSID=f0e6ee0b3f490297f0f5aba8f9f52a6e&topic=14288.msg262928#msg262928
(http://imageshack.us/a/img411/8731/1firesdl.PNG)
and the port to ndless was just a breeze...

Well this time around, things (the port) were quite a bit more complicated, namely because:
   1. due to the small lcd screen we'll have some eye pain to clear distinguish the tiles. Here i could use some help from some artists (Hayleia maybe?) willing to contribute with better looking tiles drawings.
   2. this app originally uses the mouse and in ndless/emulator we don't have it  :(. So we need to emulate it with keys (using 'SDL_WarpMouse' etc).
   3. It creates its own font for text, but that didn't work properly in ndless either. So i had to change it to use hoffa's 'nSDL_LoadFont' + 'nSDL_DrawString'.
   4. as the sdl video memory is being directly pixel-manipulated the code is written to support the 16-bit bit-depth and i do not intend to support also the non-cx models. sorry about that.

Ok, let's go straight to the 'how to use the thing':
I - First, in the calc create a folder inside 'ndless' and name it 'nMah' (or whatever). Inside 'nMah' create another folder 'Data' (this name is fixed!)
(http://imageshack.us/a/img441/3576/2nmahfiles.png)

Upload to the calc:
   a. the program 'nMah.tns' to the 'ndless/nMah' folder.
   b. the program's data files (tiles + several backgorunds) to 'ndless/nMah/Data' folder.

II- Keys/Instructions:
---------- cut here ------------>
"Mouse- emulation"
Movement: key_left, key_right, key_up, key_down or key_4, key_6, key_8, key_2
Click:        key_5 (ONLY!) dunno how to handle nspire-click key via SDL (maybe hoffa could help here? :-\)

key_return: shuffles the titles and restarts a new game.

key_7: changes tile-set    (we only have 2 at the moment)
key_9: changes background   (we have 10 available)
key_1: Undo
key_3: Redo

key_esc: Quit
<---------- cut here ------------

Have more fun,
SpiroH

Title: Re: nMah - Mahjong clone for nSpire
Post by: ElementCoder on October 02, 2012, 01:39:00 pm
Oooh nice! I love mahjong :D Downloading this right now. Good job! And looking at the screenshots, it seems the problem of distinguishing tiles isn't a very big problem :)
Title: Re: nMah - Mahjong clone for nSpire
Post by: apcalc on October 02, 2012, 03:10:04 pm
Great project!  Looks like fun! ;)
Title: Re: nMah - Mahjong clone for nSpire
Post by: Chockosta on October 02, 2012, 03:11:37 pm
Looks nice, congrats !
I will give it a try, even if I'm not too fond of Mahjong solitaire...
Title: Re: nMah - Mahjong clone for nSpire
Post by: DJ Omnimaga on October 02, 2012, 03:14:35 pm
Wow that makes my day. I do not play this that often but my mom introduced me to the game and it was very fun. Also is the fire demo the same as the one on TI-Planet? I couldn't run the TI-Planet one (nor the parralax scrolling demo) D:
Title: Re: nMah - Mahjong clone for nSpire
Post by: AzNg0d1030 on October 02, 2012, 05:33:02 pm
Aw man... I was really excited that it was Mohjang and not Mohjang solitaire...
Misleading title D:

edit: fail typos. Mahjong, not Mohjang
Title: Re: nMah - Mahjong clone for nSpire
Post by: Adriweb on October 02, 2012, 05:34:45 pm
Aw man... I was really excited that it was Mohjang and not Mohjang solitaire...
Misleading title D:
I didn't know there was another game named Mohjang than the one he ported ^^
Title: Re: nMah - Mahjong clone for nSpire
Post by: Sorunome on October 02, 2012, 08:10:20 pm
It is looking awesome so far, keep up the good work :D
Title: Re: nMah - Mahjong clone for nSpire
Post by: Yeong on October 02, 2012, 08:43:07 pm
Ooh. Mahjong. How do I play it? XP
Title: Re: nMah - Mahjong clone for nSpire
Post by: AzNg0d1030 on October 02, 2012, 10:10:37 pm
Aw man... I was really excited that it was Mohjang and not Mohjang solitaire...
Misleading title D:
I didn't know there was another game named Mohjang than the one he ported ^^
http://en.wikipedia.org/wiki/Mahjong
The original Chinese tile/card game
Mahjong solitaire came from that. (They are completely unrelated though, but they use the same tiles)
If you read the wiki for Mahjong Solitaire, it says that it was based off of Mahjong and the solitaire version was a computer game developed in the 1980s. Not the actual 'Mahjong.'

(Oh i typo'd the previous post lol not Mohjang, Mahjong FAIL)
Title: Re: nMah - Mahjong clone for nSpire
Post by: Wayne on October 03, 2012, 05:57:09 am
One of my fave games, nice work.
Title: Re: nMah - Mahjong clone for nSpire
Post by: SpiroH on October 03, 2012, 06:47:53 am
...Also is the fire demo the same as the one on TI-Planet? I couldn't run the TI-Planet one (nor the parralax scrolling demo) D:
I don't know which one you're referring too? Any direct link, so that i can check it out? But, in principle, i don't think so, or the french 'guys' would already have warned me, i gather.

Thank you all for the generous comments. Hope to see soon so more nSDL ports to nSpire. Hoffa's SDL port (http://ourl.ca/14975) is really quite a great achievement for the nSpire/ndless community. Cheers.
Title: Re: nMah - Mahjong clone for nSpire
Post by: Adriweb on October 03, 2012, 07:08:46 am
He's referring to Critor's port of "XFlame", which you can find here : http://tiplanet.org/forum/archives_voir.php?id=6045
Title: Re: nMah - Mahjong clone for nSpire
Post by: SpiroH on October 03, 2012, 01:56:46 pm
He's referring to Critor's port of "XFlame", which you can find here : http://tiplanet.org/forum/archives_voir.php?id=6045
Thanks for the link! xflame from TI-Planet works fine in CX models but not on non-CX (it reboots with ndless 3.1)! Out of curiosity, i've picked up the source and recomplied it for ndless 3.1. Again, it works only in CX models and gives a black screen in non-CXs (i've added a temporary 'srand/rand' fix to prevent reboot). This is also due to direct video memory manipulation (which isn't portable). You may have a look at the source. btw, i've rebranded it from xflame to nflame to distinguish the exe's. On more to add to the nSDL collection. Good for beginners. :)

Title: Re: nMah - Mahjong clone for nSpire
Post by: DJ Omnimaga on October 14, 2012, 08:02:52 pm
Yep it was Xflame and the parralax scrolling demos. In my case, I was never able to run both on my TI-Nspire CX. I got OS 3.1 and I tried 3 different Ndless versions (including the latest), to no avail. The calculator simply rebooted. I'll try this new version when I have some time.
Title: Re: nMah - Mahjong clone for nSpire
Post by: ajorians on June 03, 2013, 11:36:03 am
Hey Guys,

I was looking at a more fluid "mouse"; meaning by using the touchpad to get a mouse moving much faster in a game/program.

The answer is the 'touchpad_scan' function; which I haven't looked at before.  As a quick test I created Test_Touchpad.  So take a look at Test_Touchpad that is attached.  With that I can see what the values of the structure from touchpad_scan gives.  See image.

So I incorporated touchpad_scan into nMah!  So this is the same game only now the mouse should move much quicker!  I hope this is an improvement!  Give it a try and let me know!  The adjusted source is included; be sure to add the other required files that nMah needs as well!

Have a wonderful day!
Title: Re: nMah - Mahjong clone for nSpire
Post by: SpiroH on June 03, 2013, 11:40:59 am
I like it!