Author Topic: TITA IN LABYRINTHS!  (Read 388 times)

felipe

  • Member
  • ***
  • Posts: 378
  • assemble the unassembled.
TITA IN LABYRINTHS!
« on: September 20, 2017, 06:45:29 AM »
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:
Felipe.

Siekmanski

  • Member
  • *****
  • Posts: 1145
Re: TITA IN LABYRINTHS!
« Reply #1 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.

felipe

  • Member
  • ***
  • Posts: 378
  • assemble the unassembled.
Re: TITA IN LABYRINTHS!
« Reply #2 on: September 20, 2017, 10:39:17 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.

felipe

  • Member
  • ***
  • Posts: 378
  • assemble the unassembled.
Re: TITA IN LABYRINTHS!
« Reply #3 on: September 20, 2017, 10:46:19 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
Felipe.

Siekmanski

  • Member
  • *****
  • Posts: 1145
Re: TITA IN LABYRINTHS!
« Reply #4 on: September 20, 2017, 05:47:08 PM »
I didn't read the instructions.  :redface:

caballero

  • Member
  • ****
  • Posts: 785
    • Abre Ojos Ensamblador
Re: TITA IN LABYRINTHS!
« Reply #5 on: September 20, 2017, 07:37:49 PM »
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.
En un lugar de la Mancha de cuyo nombre no quiero acordarme

aw27

  • Member
  • ****
  • Posts: 857
  • Let's Make ASM Great Again!
Re: TITA IN LABYRINTHS!
« Reply #6 on: September 20, 2017, 09:14:27 PM »
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

  • Member
  • ***
  • Posts: 378
  • assemble the unassembled.
Re: TITA IN LABYRINTHS!
« Reply #7 on: September 20, 2017, 10:33:58 PM »
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:
Felipe.

HSE

  • Member
  • ****
  • Posts: 554
  • <AMD>< 7-32>
Re: TITA IN LABYRINTHS!
« Reply #8 on: September 20, 2017, 11:04:13 PM »
 :t   (Who can believe we are playing laberinths! :biggrin:)

felipe

  • Member
  • ***
  • Posts: 378
  • assemble the unassembled.
Re: TITA IN LABYRINTHS!
« Reply #9 on: September 20, 2017, 11:47:31 PM »
 :P
Felipe.

aw27

  • Member
  • ****
  • Posts: 857
  • Let's Make ASM Great Again!
Re: TITA IN LABYRINTHS!
« Reply #10 on: September 21, 2017, 12:49:10 AM »

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

  • Member
  • ***
  • Posts: 378
  • assemble the unassembled.
Re: TITA IN LABYRINTHS!
« Reply #11 on: September 21, 2017, 01:32:48 AM »
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:
Code: [Select]
; ÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷·÷         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
Felipe.

aw27

  • Member
  • ****
  • Posts: 857
  • Let's Make ASM Great Again!
Re: TITA IN LABYRINTHS!
« Reply #12 on: September 21, 2017, 02:36:15 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:

Code: [Select]
@@:
            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

  • Member
  • ***
  • Posts: 378
  • assemble the unassembled.
Re: TITA IN LABYRINTHS!
« Reply #13 on: September 21, 2017, 03:01:57 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.
Felipe.