LaughingBelly's Profile User Rating: -----

Reputation: 47 Craftsman
Group:
Active Members
Active Posts:
103 (0.08 per day)
Joined:
11-April 11
Profile Views:
1,043
Last Active:
User is offline Aug 09 2014 08:46 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   LaughingBelly has not set their status

Posts I've Made

  1. In Topic: Simple Game with Computer Turns

    Posted 2 May 2014

    You really need to understand timers better than you do currently. look through THIS and follow the example at the end.

    For any kind of GUI programming, it is very important to think in an event driven fashion. All code will be executed only in response to some event.

    Lets say you define a generic function to perform a dice roll PerformRoll. It will be called with the player information on the turn of the player.

    here are the events and actions that will happen with this approach:

    1) Game starts - we are just waiting for some event as it is player's turn
    2) Player clicks on Roll button - button click handler gets called for roll button
    Inside button click handler, you will call PerformRoll(playerNumber)
    Once PerformRoll returns, you will setup a timer for computer's turn and return. NOTE that you do not call PerformRoll for computer from here.
    3) Timer generates Timer elapsed event after the set interval - calls the timer elapsed event handler (similar to button click handler)
    Inside this handler, you will disable timer and call PerformRoll(playerNumber)
    Once PerformRoll returns, you will just return
    4) Player clicks on Roll button -... and so on

    Note that each turn will be handled as a separate event. Currently your code combined steps 2 and 3 into one step while also using timer incorrectly.

    Edit: I second tlhIn`toq's suggestion. I was about to say move away from WinForms as well. Investing time in understanding WPF and Task Parallel libraries will improve the quality of your GUIs tremendously.
  2. In Topic: Segmentation Fault 11 --- C

    Posted 20 Feb 2014

    Using this line does not do what you think it does.
    char *a[8]={"XXXXX,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday"}; 
    
    This sets the first element in the array to "XXXXX,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday". rest of the array is just random junk.

    What you probably meant was this
    char *a[8]={"XXXXX","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
    


    Note that each "" pair represents one string. If you want to initialize an array of 8 strings, you have to supply 8 strings.

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

Comments

LaughingBelly has no profile comments yet. Why not say hello?