The MASM Forum

Projects => MasmBasic & the RichMasm IDE => Topic started by: jj2007 on August 25, 2022, 10:08:07 AM

Title: Coloured rounded buttons
Post by: jj2007 on August 25, 2022, 10:08:07 AM
Spinoff from the recent buttons thread (http://masm32.com/board/index.php?topic=10267.0): test the Click me now! button :cool:
Title: Re: Coloured rounded buttons
Post by: zedd151 on August 25, 2022, 10:27:12 AM
I haven't downloaded it yet to check it out, I'm on my iPad. Does this mean you found a solution? Or did you opt for a different method?
Title: Re: Coloured rounded buttons
Post by: zedd151 on August 25, 2022, 10:52:56 AM
Looks okay over here. Windows 7 64 bit OS.
Title: Re: Coloured rounded buttons
Post by: jj2007 on August 25, 2022, 06:15:47 PM
Quote from: Swordfish on August 25, 2022, 10:27:12 AM
I haven't downloaded it yet to check it out, I'm on my iPad. Does this mean you found a solution? Or did you opt for a different method?

I opted for a full ownerdraw, with FillRect, DrawText etc. It's not yet perfect but I'm working on it. Syntax:

GuiControl MyButton, "button", "Coloured pushbutton", font -16:FW_BOLD, fcol DarkBlue, bcol LiteYellow, y310, w300, h300, BS_OWNERDRAW

You may have noted that the window is sizeable:
y310   310/1000 of main window height
w300   300/1000 of main window width
h300   300/1000 of main window height
Title: Re: Coloured rounded buttons
Post by: zedd151 on August 25, 2022, 06:25:00 PM
Cool. Glad you have gotten that all sorted out.
Title: Re: Coloured rounded buttons
Post by: jj2007 on August 27, 2022, 10:53:55 AM
New version - to the left, the new button, to the right the old one.

Still work in progress, but I am getting nearer :badgrin:
Title: Tic Tac Toe
Post by: jj2007 on August 30, 2022, 06:50:56 AM
In contrast to Swordfish (http://masm32.com/board/index.php?topic=10287.0), I have no game logic so far, this is just the graphics (and yes, this is the complete source :tongue:):

GuiParas equ "Tic Tac Toe", w172, h280, m4, b LitePink, icon Dice      ; width+height, margins, background colour
include \masm32\MasmBasic\Res\MbGui.asm
  rct=0
  Repeat 3                                      ; variable+fixed parts
        GuiControl @CatStr(<ttt>, %rct+0), "button", x000, y rct*111+1, h333, w333, bcol LiteYellow, font -32:FW_BOLD
        GuiControl @CatStr(<ttt>, %rct+1), "button", x333, y rct*111+1, h333, w333, bcol LiteGreen, font -32:FW_BOLD
        GuiControl @CatStr(<ttt>, %rct+2), "button", x666, y rct*111+1, h333, w333, bcol LiteBlue, font -32:FW_BOLD
        rct=rct+3
  Endm
  GuiControl MyStatus, "statusbar", wRec$(Str$("Last ID=%i, common controls version ", %IdCt)+ComCtl32$())
Event Key
  .if VKey==-VK_ESCAPE
        invoke SendMessage, hGui, WM_CLOSE, 0, 0
  .endif
Event Command
  If_ nCode==BN_CLICKED Then SetWin$ <rv(GetDlgItem, hGui, MenuID)>="X"
GuiEnd
Title: Re: Coloured rounded buttons
Post by: zedd151 on August 30, 2022, 06:55:30 AM
For the game logic (AI lol)
Test for winning move first. If found, take it
Next test for blocking move, if found take it. Sometimes more than one though, in that case computer will lose.
If none of those are found test the center square, take it.
Else a random move.


daydreamer is also contemplating a tic tac toe game


We should have each other's AI play against each other. lol
Title: Re: Coloured rounded buttons
Post by: jj2007 on August 30, 2022, 07:12:32 AM
Quote from: Swordfish on August 30, 2022, 06:55:30 AMWe should have each other's AI play against each other. lol

One day - right now, I've too many unfinished projects :sad:
Title: Re: Coloured rounded buttons
Post by: zedd151 on August 30, 2022, 07:13:43 AM
Rumour has it that you are King in that regard
Title: Re: Coloured rounded buttons
Post by: jj2007 on September 01, 2022, 10:19:10 AM
Yeah, that's true :biggrin:

I am just playing around :cool:

Btw this is Win7-64, on Win10 the fish looks different. I also wonder why it remains black & white on Win10 :sad:

(https://jj2007.eu/pics/TicTacToe.png)
Title: Re: Coloured rounded buttons
Post by: zedd151 on September 01, 2022, 10:22:24 AM
I don't know if it will be fun, but it looks fun(ny).
Where's the X and O?  :biggrin:
I'll look at it later...
Title: Tic Tac Toe
Post by: jj2007 on September 02, 2022, 10:18:53 AM
It still looks as above, but now the logic is implemented. Still with little glitches, but one can play the game :cool:
Title: Tic Tac Toe
Post by: jj2007 on September 02, 2022, 08:57:02 PM
Version 3, almost perfect, and no font problems :cool:
Title: Re: Coloured rounded buttons
Post by: jj2007 on September 02, 2022, 11:10:06 PM
Version 4 has a manual mode: type m

If manual mode is on, Shift click plays for the software. This is basically for verifying if there are better moves than what the software chooses for itself. For example:

P#1 P#2
r0c0 r2c2
r0c2 r0c1
r2c0 r1c0
r1c1 player won


Does anybody know a sequence that allows player #2 to win?
Title: Re: Coloured rounded buttons
Post by: zedd151 on September 03, 2022, 02:06:11 AM
Quote from: jj2007 on September 02, 2022, 11:10:06 PM
Version 4 has a manual mode: type m

If manual mode is on, Shift click plays for the software. This is basically for verifying if there are better moves than what the software chooses for itself. For example:

P#1   P#2
r0c0   r2c2
r0c2   r0c1
r2c0   r1c0
r1c1   player won


Does anybody know a sequence that allows player #2 to win?


In reply #7 in this thread, I warned of scenarios like this. First player always has advantage regardless of second players logic or 'strength'. Better explanation in reply to your duplicate posting in campus -  here (http://masm32.com/board/index.php?topic=10267.msg112875#msg112875)
Title: Re: Tic Tac Toe
Post by: zedd151 on September 24, 2022, 09:46:34 AM
Just took a look at your tic tac toe again playing with it. Apparently you didn't lock the players ability to move when the computer is 'thinking'. computers piece can be overwritten.