i need help with a few things

This is a discussion on i need help with a few things within the A Brief History of Cprogramming.com forums, part of the Community Boards category; i am doing project to work on my programming skills first i would like to create a window and have ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    44

    i need help with a few things

    i am doing project to work on my programming skills first i would like to create a window and have an oject in the window and it would be a certain color and when a user presses an arrow key i want th place where it was at turn back to black i know how to get arrow key input so i just need to know how to get colors and how should i allocate memory for the window?? use an array or malloc()? thank you

  2. #2
    Registered User
    Join Date
    Mar 2004
    Posts
    44

    help

    ok in about fifteen minutes i have been able to come up with this code does anybody have any suggestions on how i should put in the cases for where to move
    Code:
    #include "stdafx.h"
    
    int winarray[20][12];
    int move(int where);
    
    enum
    {
      KEY_ESC     = 27,
      ARROW_UP    = 256 + 72,
      ARROW_DOWN  = 256 + 80,
      ARROW_LEFT  = 256 + 75,
      ARROW_RIGHT = 256 + 77
    };
    
    static int get_code ( void )
    {
      int ch = getch();
    
      if ( ch == 0 || ch == 224 )
        ch = 256 + getch();
    
      return ch;
    }
    
    
    int main(int argc, char* argv[])
    {
    	char ch;
    	int count,count2,mover;
    	for(count=0;count<20;count++)
    		winarray[count][0]=1;
    	for(count=0;count<12;count++){
    		winarray[1][count]=1;
    		winarray[20][count]=1;
    	}
    mover=2;
    winarray[1][1]=mover;
    winarray[1][2]=mover;
    winarray[2][1]=mover;
    winarray[2][2]=mover;
    
    	for(count=0;count<20;count++){
    		if(count<12){
    			switch(winarray[count][count]){
    			case 0:{
    				printf(" ");
    				   break;
    				   }
    			case 1:{
    				printf(".");
    				   break;
    				   }
    			case 2:{
    				printf("[]");
    				   }
    			}
    		}
    		if(count<=20){
    			switch(winarray[count][12]){
    			case 0:{
    				printf(" ");
    				break;
    				   }
    			case 1:{
    				printf(".");
    				   }
    			case 2:{
    				printf("[]");
    			}
    		}
    		if(count==20){
    			printf("\n");
    		}
    	}
    while ( ( ch = get_code() ) != KEY_ESC ) {
        switch ( ch ) {
    	case ARROW_UP:{
    move(1);
    break;
    }
    	case ARROW_DOWN:{
    move(2);
    break;
    }
    	case ARROW_LEFT{
    move(3);
    break;
    	}
    	case ARROW_RIGHT{
    move(4);
    break;
    	}
    }
    					
    
    	return 0;
    }
    
    
    int move(int where){
    	switch(where){
    	case 1:{}		/*move up*/
    	case 2:{}		/*move down*/
    	case 3:{}		/*move left*/
    	case 4:{}		/*move right*/
    	}
    
    return 0;
    }

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    44

    help

    if you find any glitches or bugs in this code please post that to thanks

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,417
    Stop spamming the board with your multiple posts
    dos game help
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Suggestions for things to study
    By Mastadex in forum Windows Programming
    Replies: 5
    Last Post: 08-18-2008, 09:23 AM
  2. Plants that eat things
    By StinkyRyan in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 07-05-2004, 03:41 PM
  3. How are things looking
    By cyberCLoWn in forum C++ Programming
    Replies: 8
    Last Post: 01-15-2004, 01:53 PM
  4. Selecting things on the canvas
    By Barjor in forum Windows Programming
    Replies: 0
    Last Post: 08-30-2001, 02:10 PM
  5. Help with these three things...
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 08-26-2001, 07:05 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21