News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

TITA IN LABYRINTHS!

Started by felipe, September 20, 2017, 06:45:29 AM

Previous topic - Next topic

felipe

I know i said: no more console programs, now i will go to gui fase  ;). But while i learn to do that , here i come with a little console game  :icon_mrgreen:.

Very simple, with complete source code, well commented (hopefully)  :P.

And you can do your own labyrinths (coding, not in the game  :eusa_dance:) or whatever you want to do with the code  8).

Please give it a try and let me know your comments, criticism or whatever  :greensml:. Please note that i didn't try to optimize the code under any criteria other than readability (maybe)  :idea:. But you can do it for your own version (if you want)  ;).

Now enjoy TITA IN LABYRINTHS  :greenclp:

or not   :(

  :lol:

Siekmanski

Hi felipe,

Nice game, but when I press an arrow key it jumps 2 places at once instead of 1, so I can't get below the 7th row.
Creative coders use backward thinking techniques as a strategy.

felipe

Quote from: Siekmanski on September 20, 2017, 08:02:46 AM
Hi felipe,

Nice game, but when I press an arrow key it jumps 2 places at once instead of 1, so I can't get below the 7th row.

Indeed that's correct. That's the reason why the instructions said:

"If you can't pass into a clean aisle just use 2 arrows in a diagonal move."

That means using for example left key + down key to go left and down in such situation.

Thanks a lot for your words!  :t

felipe

Quote from: Siekmanski on September 20, 2017, 08:02:46 AM
when I press an arrow key it jumps 2 places at once instead of 1.

Btw,  i couldn't find the reason why this was happening. I tryed a lot of things, even change the font for the console. So i decided to go on with the game like that and include that particular condition into the game rules. :P

Siekmanski

I didn't read the instructions.  :redface:
Creative coders use backward thinking techniques as a strategy.

avcaballero

Interesting Felipe, but I am not able to get the right way because when I try it the happy face gives two steps, so I cannot be in front of the exit.

aw27

It works and reminds me of the 80's games that used to run on machines with 1KB RAM.  :t
However, I don't think it is possible to reach the end of the labyrinth., It is.

felipe

Thanks for trying it and for your words.  :t

Caballero see the instructions and my first reply in this post.

When you find that situation, use 2 keys at the same time (left arrow + up arrow or ....) accordingly to the situation (the place where tita is and where the clear aisles are...).

I have go through the 4 labyrinths many times at super speed (hahaha). Well, because i know the exit, but as aw27 said is possible. Maybe a little tricky, but possible.  :redface:

Actually, that weird problem wasn't planned, but as i said i coundn't find the reason or the solution for it. Probably is some kind of "windows console's inherinted characteristic", like an auto formatted thing or similar.

:icon14:

HSE

 :t   (Who can believe we are playing laberinths! :biggrin:)
Equations in Assembly: SmplMath


aw27

Quote from: felipe on September 20, 2017, 10:33:58 PM

Actually, that weird problem wasn't planned, but as i said i coundn't find the reason or the solution for it.

:icon14:

On the ReadConsoleInput you must stay in a loop until bKeyDown is true, otherwise you will react to 2 messages, 1 for keydown and 1 for keyup, and the cursor moves 2 positions instead of 1.
Do you understand, or I am talking Greek? :bgrin:

felipe

aw27, you are a genius!   :t

Now it works like it should. I attach the source with the correction and the exe fully functional (no tricky things).  ;)

This correct the problem as aw27 said:

; ÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷         Thanks aw27!


            sub                 esi,10                                              ; input_rec start.                               

            cmp                 byte ptr[esi+4],TRUE                                ; bKeyDown element. Key should be pressed to move tita,
            jne                 notyet0                                             ;  and should not move when it is released (FALSE).

            add                 esi,10                                              ; wVirtualKeyCode again.

; ÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷



This of course is written in a redundant way (i mean the use of esi for addressing). But i have no intention to optimize this now, i just want to point that the problem was corrected, the game works now how it should and that you still can do whatever you want with the code.   :icon_mrgreen:

I first did the correction to the first labyrinth only, now i have done it for all of them. Also i have eliminated in the instructions the tricky solution for that tricky problem.  :t

aw27

Quote from: felipe on September 21, 2017, 01:32:48 AM
This of course is written in a redundant way (i mean the use of esi for addressing).

No doubt, you could have declared this way
input_rec INPUT_RECORD <>
and not this way
input_rec   dword               4 dup (?)

Then you could watch for the keydown like this:


@@:
            push                offset rec_reads
            push                1 
            push                offset input_rec
            push                stdin
            call                ReadConsoleInput
    cmp dword ptr input_rec.KeyEvent.bKeyDown, 0
    je @b


:t

felipe

Quote from: felipe on September 21, 2017, 01:32:48 AM

; ÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷         Thanks aw27!


            sub                 esi,10                                              ; input_rec start.                               

            cmp                 byte ptr[esi+4],TRUE                                ; bKeyDown element. Key should be pressed to move tita,
            jne                 notyet0                                             ;  and should not move when it is released (FALSE).

            add                 esi,10                                              ; wVirtualKeyCode again.

; ÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷



You are right, at least that line should say: cmp dword ptr[esi+4],TRUE. I think that happen when you try to fix something to fast. (Seems like i'm trying to get rid of this job).  :P
Corrected this in the new attachment.