Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Crazy Scripting : Dingbat Flipper 45L


  • Please log in to reply
26 replies to this topic
SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Dingbat Flipper 45L - A Memory and Concentration based Game.Snapshot: DF45L_SS01.png 26.7Kb
Posted Image
The Game:
The GUI contains 36 pairs of identical Dingbats. You have to flip open each of them and find the pairs. Consecutive flips on an identical pair earns you them. The catch: No more than two Dingbats will be open at a given time. You have to fully rely on your memory and concentration to play this Game. To finish the game, you will have to find all the 36 pairs.

[*:3qvdil97]Some of the Dingbats might look similar ( especially Monalisa ).
[*:3qvdil97]The Game Timer stops if the GUI is not active ( or is Minimised ).
Credit: It was adapted from an example given in the AHK Documentation : FormatTime
[*:3qvdil97]F2 Reloads the Script.
Gui, +AlwaysOnTop 
Gui,Font,s28, Webdings
Loop 36                             
 Ix:=A_Index, Ch.=Chr(158+Ix) "|" Chr(158+Ix) ((Ix<36) ? "|" : "") 
Sort,Ch,D| Random
X:=10, Y:=10, R:=1, C:=1, Ix:=1
Loop,Parse,Ch,| 
                        {
                           Gui,Add,Button,x%X% y%Y% w46 h46 vB%Ix% gMainProcedure
                           X:=X+50, C:=C+1, Ix:=Ix+1
                           If (C>9)
                              R:=R+1, C:=1, Y:=Y+50, X:=10
                        } 
Gui,Font,S8 Bold,Tahoma
Gui,Margin,10,10
Gui,Add,StatusBar
e:=SB_SetParts(75,75,250), CL:=0, FL:=0, A_Time:=SubStr(A_Now,1,8)  
Gui,Show,,Dingbat Flipper 45L
SetTimer,GameTimer,1000
Return ;                                                   [ End of Auto-Execute Section ]

F2::ReLoad

MainProcedure: ;                                                        [ Main Procedure ]
  iNo:=Substr(A_GuiControl,2,2)
  If (iNo!=S1 and iNo!=S2 and AR!=1) {
  e:=GuiC(N,"B" iNo,GetF(Ch,iNo)),   S0:=S1, S1:=S2, S2:=iNo,     e:=GuiC(N,"B" S0), AR:=1
  If ( GetF(Ch,S1) [color=red]==[/color] GetF(Ch,S2) ) ;               [color=red]== is used for case sensitive matching[/color]
     e:=GuiC("Disable","B" S1),      e:=GuiC("Disable","B" S2),     S1:=0, S2:=0, FL:=FL+1
  CL:=CL+1, AR:=0,     SB_SetText("`tClicks: " CL,1),   SB_SetText("`tFlips: " FL "/36",2)
  IfEqual,FL,36, Gui,Show,,GAME OVER!       Press <F2> to play again
} Return

GameTimer: ;                                                                [ Game Timer ]
  If (WinActive("Dingbat Flipper 45L") And CL>0) {
  A_Time+=1,S
  FormatTime,MMSS,%A_Time%,mm:ss
  SB_SetText("`t" MMSS,4)
} Return 

GetF(Str="",Fld=1)        { ;                                                   GetField()
  Loop,Parse,Str,|
    IfEqual,A_Index,%Fld%, Return,A_LoopField
}

GuiC(P1="",P2="",P3="")   { ;                                                 GuiControl()
  GuiControl,%P1%, %P2%,%P3% 
}

GuiClose:
  ExitApp

If you have a Memory of GoldFish ( like me! ), you may try Auto-Solver which I wrote for debugging this game.

Thank you for trying this Game. ;)[/list]Edit1: Gui,Font,s28 Bold, Webdings changed to Gui,Font,s28, Webdings

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
I love this kind of game! Impressive that you made it with so little code (although you abused of the multiple expressions per line).
It is quite hard, you should allow add a little GUI to choose the size. Also changing the color of the icons might help too.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

I love this kind of game! Impressive that you made it with so little code (although you abused of the multiple expressions per line).


Thank you. It is a simple variant of Icon Flipper ( See. Snapshot ) which was 150 lines. I challenged myself on writing a strict 45 Line code. In IE kiosk mode ( 1024x768 ) the full code fits a single screen. :D.

It is quite hard, you should allow add a little GUI to choose the size. Also changing the color of the icons might help too.


I just noticed I have used the Bold in Font Options. I least guessed Wingdings would respond to it. :(. It looks better if you remove it.
I will be posting the code for Icon-Flipper soon. The kids@home feel that it is a better version. I have used API AnimateWindows() to Slide-Open & Slide-Close the Icons. The current version is creating redrawing problem in Win XP ( It runs fine in Win2K & 98SE though ). I hope I will find a way to overcome it.

Did you try the Auto-Solver?. It is my first mouse based automation script.

Thanks. :)

Rabiator
  • Members
  • 292 posts
  • Last active: Aug 29 2016 09:29 PM
  • Joined: 17 Apr 2005
@Skan
Your game is brilliant! 8)
I tried out the solver, too, it works very well. Watching it radiates some mysticism, I'll need a closer look at the source.

__________________________________________
Created with BBCodeWriter 7.0 - the one and only :D

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Thanks for trying it Rabiator. :D

Elevator_Hazard
  • Members
  • 297 posts
  • Last active: Feb 07 2011 12:10 AM
  • Joined: 28 Oct 2006
I'm on the linux computer, but it looks great! Beats mine by a lot, I used images; it never occurred to me that I could use that font instead of images (I only used 8 images because I got tired of extracting the icons from programs). And the only reason I really made it was to try and show my parents I'm not messing with stuff :roll:

Haven't tried it, I might when I'm not on linux, but it looks great, so does the code.
Changed siggy at request of ahklerner :D

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
Nice one. Why don't you make it show all the pics for a second or two at the beginning so we can use our memory instead of randomly clicking.

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
Well, this way, it is a bit like MineSweeper... :-)

Side note: most Memory programs I played with hide the previous pair of card when flipping a new one. You choose to always have a pair of card displayed, which is a bit easier. It is an interesting variant.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

Haven't tried it, I might when I'm not on linux, but it looks great, so does the code.


Thanks.. Do try it when you have time. :D

Nice one. Why don't you make it show all the pics for a second or two at the beginning so we can use our memory instead of randomly clicking.


Thank for trying this. I like your idea and will be including it in my next variant. Here is a simple implementation:

Gui, +AlwaysOnTop
Gui,Font,s28, Webdings
Loop 36                             
 Ix:=A_Index, Ch.=Chr(158+Ix) "|" Chr(158+Ix) ((Ix<36) ? "|" : "")
Sort,Ch,D| Random
X:=10, Y:=10, R:=1, C:=1, Ix:=1
Loop,Parse,Ch,|
                  {
                     Gui,Add,Button,x%X% y%Y% w46 h46 vB%Ix% gMainProcedure, [color=red]%A_LoopField%[/color]
                     X:=X+50, C:=C+1, Ix:=Ix+1
                     If (C>9)
                        R:=R+1, C:=1, Y:=Y+50, X:=10
                  }
Gui,Font,S8 Bold,Tahoma
Gui,Margin,10,10
Gui,Add,StatusBar
e:=SB_SetParts(75,75,250), CL:=0, FL:=0, A_Time:=SubStr(A_Now,1,8) 
Gui,Show,,Dingbat Flipper 45L
SetTimer,GameTimer,1000
[color=red]Sleep 400               ;   To avoid Double-click launch of script conflict with next line
KeyWait, LButton, D T10 ;         Wait for Button press or 10 seconds whichever is earlier
Loop 72                            ; Operate on all 72 Buttons
 Ix:=A_Index, GuiC("", "B" Ix,"")  ; Nullify the button caption[/color]
Return ;                                                   [ End of Auto-Execute Section ]

F2::ReLoad

MainProcedure: ;                                                        [ Main Procedure ]
  iNo:=Substr(A_GuiControl,2,2)
  If (iNo!=S1 and iNo!=S2 and AR!=1) {
  e:=GuiC(N,"B" iNo,GetF(Ch,iNo)),   S0:=S1, S1:=S2, S2:=iNo,     e:=GuiC(N,"B" S0), AR:=1
  If ( GetF(Ch,S1) == GetF(Ch,S2) ) ;               == is used for case sensitive matching
     e:=GuiC("Disable","B" S1),      e:=GuiC("Disable","B" S2),     S1:=0, S2:=0, FL:=FL+1
  CL:=CL+1, AR:=0,     SB_SetText("`tClicks: " CL,1),   SB_SetText("`tFlips: " FL "/36",2)
  IfEqual,FL,36, Gui,Show,,GAME OVER!       Press <F2> to play again
} Return

GameTimer: ;                                                                [ Game Timer ]
  If (WinActive("Dingbat Flipper 45L") And CL>0) {
  A_Time+=1,S
  FormatTime,MMSS,%A_Time%,mm:ss
  SB_SetText("`t" MMSS,4)
} Return

GetF(Str="",Fld=1)        { ;                                                   GetField()
  Loop,Parse,Str,|
    IfEqual,A_Index,%Fld%, Return,A_LoopField
}

GuiC(P1="",P2="",P3="")   { ;                                                 GuiControl()
  GuiControl,%P1%, %P2%,%P3%
}

GuiClose:
  ExitApp

Side note: most Memory programs I played with hide the previous pair of card when flipping a new one. You choose to always have a pair of card displayed, which is a bit easier. It is an interesting variant.


It was suggested by the end-users. ( My Nephews & Nieces ) :D

Regards, :)

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
Hi Skan,

Looks great. One thing though.
If I understood it correctly, you used the portion (>158) of the extended characters (>127).
Then, I'm afraid it might not work for the systems using the double-byte character sets, i.e., CJK characters.
I don't know if there is other choices, though. I just thought better let you be aware of it.

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Dear Sean, :)

Looks great.


Thanks. Please try it when you are free :)

If I understood it correctly, you used the portion (>158) of the extended characters (>127).
Then, I'm afraid it might not work for the systems using the double-byte character sets, i.e., CJK characters.
I don't know if there is other choices, though. I just thought better let you be aware of it.


The script runs as desired in English version of WinXP, Win2k & Win98SE

Previously, I was using the regular ASCII set and the script was matching lowercase with uppercase ( like a with A ) creating chaos. :lol:. I did not know how to make a case-sensitive match ( :oops: ) and so as a workaround I resorted to use the Extended ASCII. Later, I found out I had to use == operator for exact match. But then the kids had already started liking it so I left it as is.

I had to google to find about CJK characters :O . Thanks for the info.
If any one is having problems, they can always change it to 64

:)

Elevator_Hazard
  • Members
  • 297 posts
  • Last active: Feb 07 2011 12:10 AM
  • Joined: 28 Oct 2006
How? Because they just look like Verdana characters to me :(
Changed siggy at request of ahklerner :D

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
I am not too sure of who you answer, but if you see regular (accented?) letters instead of images, check that you have the Webdings characters installed on your computer. It should come with IE, IIRC, and it is available for free on Microsoft site.
I tried with Wingdings, but with similar clock faces, it is even harder! Wingdings 2 and Wingdings 3 are not better.
But you can explore the world of graphical fonts, I have one with cats, for example...
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

Elevator_Hazard
  • Members
  • 297 posts
  • Last active: Feb 07 2011 12:10 AM
  • Joined: 28 Oct 2006
I have Webdings... Oh well I don't know I've also tried the Wingdings but to no avail...

Skan you should add this to the script listing on the autohotkey wiki page under game section.
Changed siggy at request of ahklerner :D

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

I have Webdings... Oh well I don't know I've also tried the Wingdings but to no avail...


Did you try Webdings in WordPad? If not try typing something & set it to Webdings!

Skan you should add this to the script listing on the autohotkey wiki page under game section.


Thanks. But I do not know how to! :roll: