Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7775699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:41:56+00:00 2026-06-01T17:41:56+00:00

We just started learning windows programming in C++. We have to make a program

  • 0

We just started learning windows programming in C++. We have to make a program that has 4 die on the screen, and when the user presses ‘SpaceBar’, the die roll, or the number of dots on the die change randomly. Our professor hasent given us a lot of information, so I am kind of just looking for some direction.

Right now, I have 4 squares drawn on the screen, made with the Rectangle() function.

Rectangle(hDC,30,100,130,200);
Rectangle(hDC,180,100,280,200);
Rectangle(hDC,330,100,430,200); 
Rectangle(hDC,480,100,580,200);  

My question is 1) how would I go about drawing dots on these ‘squares’ and not on the ‘screen’. So if I move the die upwards, the dots move with the square and dont just stay stationed painted on the screen. And 2.) How would I go about making those dots randomly change when spacebar is pressed (simulating that they have been rolled)?
Just looking for some direction, thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:41:56+00:00Added an answer on June 1, 2026 at 5:41 pm

    1)
    You will still have to draw them on the screen, but you can structure your program to realize the dots as part of the square.

    void moveSquare()
    {
        //change square position
        //change dots positions the same as you changed the square
    }
    

    2)
    You can capture keypresses in your window with the WM_KEYDOWN and WM_KEYUP messages, or the WM_CHAR message. Just start a chain of changing how many dots are supposed to appear on the die when space is pressed (SetTimer could be handy), and let WM_PAINT do the work of painting the dots (or call something to calculate the positions of the dots, and let WM_PAINT loop through each dot it needs to draw.

    void OnSpacePressed()
    {
        //start changing dots every so often, handled elsewhere
        //maybe check if finished rolling before doing so
    }
    
    void calculateDotPositions()
    {
        switch (numberOfDots) {...} //hint: use the square as a reference point
    }
    
    void OnPaint()
    { 
        //paint each sqaure
        //paint each dot in the correct position, which should be updated with square
    }
    
    void OnChangeDots()
    {
        //change number of dots
        //also start a new change to happen later if not done rolling
    }
    

    For drawing dots, use Warren P’s reference link.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started learning how to program Windows GUI's using the low level
I have just started learning about socket programming and learned about winsock and achieved
I just started learning C, and wrote my hello world program: #include <stdio.h> main()
I just started learning C, and wrote my hello world program: #include <stdio.h> main()
I've just started learning WPF and like the power of databinding it presents; that
I have just started learning Javascript. I want Hello World! to be written to
I just started learning Backbone.js, and have been working on (what else) a simple
Just started learning PySide and is having problem with QTimer I have this #!/usr/bin/python
I just started learning C++ couple of weeks ago. So now I have this
I've just started learning winsock through the Beej's guide to network programming book. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.