> On May 18, 2018, at 9:16 AM, Adik <ademkolli...@gmail.com> wrote:
> 
> 
> 
> On Friday, May 18, 2018 at 1:00:49 AM UTC+1, Adik wrote:
> im trying to create a (start new game) button to refresh the game (clean 
> board).. attached is the code i have
> I have already created a reset button that closes the whole game window but i 
> just want it to wipe the previous game data and start new game.
> 
> Thankyou in advance.
> 
> 
> 
> 
> 
> I have recently created a button that gets rid of the values in the game but 
> it is not playable after that
> this is the code i came up with:
> (define startnewgamebut (new button%
>                              [parent myFrame]
>                              [label "Start New Game"]
>                              [callback (λ (m j)
>                                          (updateState 2 2 0)
>                                          (updateState 2 1 0)
>                                          (updateState 2 0 0)
>                                          (updateState 1 2 0)
>                                          (updateState 1 1 0)
>                                          (updateState 1 0 0)
>                                          (updateState 0 2 0)
>                                          (updateState 0 1 0)
>                                          (updateState 0 0 0)
>                                          (update)
> 
>                                          
>                                          )]))
> 
> 
> any help?


I looked at your code and added enough for a reset last night. BUT, I will say 
your code is so disorganized, it wouldn’t help you if I sent along my result. 

Question: have you heard of the model-view-control (MVC) pattern/architecture? 
If not, you must read up on it and separate out the state of the TTT game from 
the visual representation. Then you need to develop a connection between the 
two (control). At that point, the reset button will look more or less like 
this: 

        [callback (lambda (_m _j) (reset-state) (reset-view))]

— Matthias


-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to