AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Crazy Scripting : Dingbat Flipper 45L
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
SKAN



Joined: 26 Dec 2005
Posts: 5595

PostPosted: Tue May 01, 2007 11:45 am    Post subject: Crazy Scripting : Dingbat Flipper 45L Reply with quote

    Dingbat Flipper 45L - A Memory and Concentration based Game.
    Snapshot: DF45L_SS01.png 26.7Kb


    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.

    • Some of the Dingbats might look similar ( especially Monalisa ).
    • 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
    • F2 Reloads the Script.


    Code:
    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) == 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


    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. Wink

Edit1: Gui,Font,s28 Bold, Webdings changed to Gui,Font,s28, Webdings


Last edited by SKAN on Tue May 01, 2007 5:24 pm; edited 1 time in total
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Tue May 01, 2007 4:36 pm    Post subject: Reply with quote

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.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 5595

PostPosted: Tue May 01, 2007 5:48 pm    Post subject: Reply with quote

PhiLho wrote:
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. Very Happy.

Quote:
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. Sad. 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. Smile
Back to top
View user's profile Send private message
Rabiator



Joined: 17 Apr 2005
Posts: 264
Location: Sauerland

PostPosted: Tue May 01, 2007 7:50 pm    Post subject: Reply with quote

@Skan
Your game is brilliant! Cool
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 Very Happy
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5595

PostPosted: Tue May 01, 2007 8:42 pm    Post subject: Reply with quote

Thanks for trying it Rabiator. Very Happy
Back to top
View user's profile Send private message
Elevator_Hazard



Joined: 28 Oct 2006
Posts: 303
Location: Illinois

PostPosted: Wed May 02, 2007 1:58 am    Post subject: Reply with quote

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 Rolling Eyes

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 Very Happy
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 5009
Location: imaginationland

PostPosted: Wed May 02, 2007 9:40 am    Post subject: Reply with quote

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.
_________________

RegExReplace("irc.freenode.net/autohotkey", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2")
Back to top
View user's profile Send private message Visit poster's website
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Wed May 02, 2007 11:09 am    Post subject: Reply with quote

Well, this way, it is a bit like MineSweeper... Smile

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.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 5595

PostPosted: Wed May 02, 2007 7:43 pm    Post subject: Reply with quote

Elevator_Hazard wrote:
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. Very Happy

Titan wrote:
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:

Code:
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, %A_LoopField%
                     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
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

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


PhiLho wrote:
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 ) Very Happy

Regards, Smile
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1255

PostPosted: Thu May 03, 2007 11:07 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5595

PostPosted: Thu May 03, 2007 11:33 pm    Post subject: Reply with quote

Dear Sean, Smile

Quote:
Looks great.


Thanks. Please try it when you are free Smile

Quote:
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. Laughing. I did not know how to make a case-sensitive match ( Embarassed ) 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 Surprised . Thanks for the info.
If any one is having problems, they can always change it to 64

Smile
Back to top
View user's profile Send private message
Elevator_Hazard



Joined: 28 Oct 2006
Posts: 303
Location: Illinois

PostPosted: Fri May 04, 2007 12:00 am    Post subject: Reply with quote

How? Because they just look like Verdana characters to me Sad
_________________
Changed siggy at request of ahklerner Very Happy
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Fri May 04, 2007 5:48 am    Post subject: Reply with quote

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...
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Elevator_Hazard



Joined: 28 Oct 2006
Posts: 303
Location: Illinois

PostPosted: Sat May 05, 2007 7:29 pm    Post subject: Reply with quote

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 Very Happy
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 5595

PostPosted: Sat May 05, 2007 9:29 pm    Post subject: Reply with quote

Elevator_Hazard wrote:
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!

Elevator_Hazard wrote:
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! Rolling Eyes
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group