Thread: Help with DarkGDK pogramming

  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    3

    Help with DarkGDK pogramming

    I am new to programming so I dont know a whole lot yet, but I start working on an assignment for my programming class and have hit a few snags...

    Here is the problem from the book:

    In a program write a function named drawPattern. The draw function should accept two arguments: one for the patterns width and another for the height. When the program runs the darkgdk function should ask the user for the width and height of the pattern, and then pass these values as arugments to the drawpattern function.

    so far I got:
    Code:
    #include "DarkGDK.h"
    
    void __cdecl drawPattern(int);
    
    void DarkGDK()
    {
    	drawPattern(100);
    
    	dbWaitKey();
    
    }
    
    void drawPattern(int width, int height)
    {
    	int height = dbScreenHeight();
    	int width = dbScreenWidth();
    
    	int x = width/2;
    	int y = height/2;
    
    	dbPattern(x,y,x,y);
    
    }
    Any help would be much appreciated.
    Last edited by Salem; 09-20-2010 at 10:52 PM. Reason: Added code tags - learn to use them yourself

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Instead of going for the whole pattern right away, how about something simpler like
    - a pixel
    - a line
    - a triangle
    etc
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Sep 2010
    Posts
    3
    I have worked my way through that and have pretty much breezed through the book up til this point....

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Perhaps you should breeze through it a bit more thoroughly then.

    Because "easy", "easy", "easy" then "clueless" means you probably missed something along the way.

    Did you try the examples (or questions) in previous chapters?
    Did you try to modify them?
    Did you try to break them?
    If not, then I'd say you're moving too fast.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Sep 2010
    Posts
    3
    Ok so been kinda working through it and I got this much now:

    #include "DarkGDK.h"

    void drawPattern(int, int);

    void DarkGDK()
    {
    int firstNum, secondNum;

    dbPrint("Enter the patterns width:");
    firstNum = atoi(dbInput());

    dbPrint("Enter the patterns height:");
    secondNum = atoi(dbInput());

    }

    void drawPattern(int firstNum, int secondNum)
    {
    DWORD white = dbRGB(255,250,250);
    DWORD black = dbRGB(0,0,0);

    dbClear(255,250,250);

    dbInk(black, white);

    dbLine(0,0,640,480);
    dbLine(640,0,0,480);
    dbLine(320,0,320,480);
    dbLine(0,240,640,240);


    dbInk(black, black);
    dbBox(int firstNum, int secondNum);


    dbWaitKey();

    }

    but what I cant seem to figure out is how to create the dbBox in the center of the screen with just the two inputs given by the user....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM

Tags for this Thread