Thread: Randomizing pixel location

  1. #1
    Registered User
    Join Date
    Dec 2019
    Posts
    1

    Randomizing pixel location

    For a class I need to create a simple computer game. Here is the general idea of that game.
    When the up button is pressed, the invader will start moving and a dot will appear on the screen. Use the joystick to move the invader so that it hits the dot. If it hits the dot, the dot disappears and another one appears somewhere else on the screen. Hit as many dots as you can. The game ends either when 28 seconds are up, or when the invader hits the boundary rectangle. The score is the number of dots hit. After 7 seconds, 1 obstacle appears on the screen. After 14 seconds, another obstacle appears on the screen. After 21 seconds a third obstacle appears on the screen. (obstacles will be rectangles that appear on the screen at the given increments).

    I haven't had much prior experience with C and and am struggling with programming the dot to randomly appear, disappear when it gets hit, and then randomly appear somewhere else. If anyone could help me with how to program that it would be greatly appreciated.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    This cannot be done purely in standard C, so it would be helpful to know what relevant libraries your teacher has taught or recommended that you use for this exercise.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 05-02-2016, 08:47 PM
  2. pixel by pixel graphics, what's the name of this technique?
    By PedroTuga in forum Game Programming
    Replies: 6
    Last Post: 12-14-2012, 07:06 PM
  3. randomizing?
    By cerin in forum C++ Programming
    Replies: 55
    Last Post: 02-03-2005, 06:58 PM
  4. Randomizing
    By Morph in forum C++ Programming
    Replies: 18
    Last Post: 01-26-2003, 06:36 PM

Tags for this Thread