What do I put before:


Code:
    if(keydownlast(KEY_PRGM_UP) && y>129)
    y-=8;
    if(keydownlast(KEY_PRGM_DOWN) && y<137)
    y+=8;
    if(keydownlast(KEY_PRGM_SHIFT) && y == 129)
    break;


I don't know what I need to put.
Hmm, will you specify? By "put" do you mean the while loop? Or everything except what you have here? Thanks
This is what I am using for paint.

Code:

GetKey(&key);
      if (keydownlast(KEY_PRGM_UP) && curY > 8) {
         curY = curY-1;
         CopySprite(cursor, curX, curY, 16, 16);
         } else if (keydownlast(KEY_PRGM_DOWN) && curY < 160) {
         curY = curY+1;
         CopySprite(cursor, curX, curY, 16, 16);
      }

Hope that helps at all.
I know there is a statement to put before the "int main() { " and after the "#include". I don't know what though.
You would prototype the functions you are using and declare global variables, if you're using any.
I'm not getting what you are saying.
Remember to prototype all of the funtions in that set like:


Code:
const unsigned short* keyboard_register = (unsigned short*)0xA44B0000;
unsigned short lastkey[8];
unsigned short holdkey[8];

void keyupdate(void);
int keydownlast(int key);
int keydownhold(int key);


Then, a game loop would look like this:


Code:
while(1) {
   keyupdate();
   ...
   // your code for key detection here
}


The keyupdate() function updates all the global key arrays, so that keydownlast and keydownhold can work correctly.

For more information, see WikiPrizm: http://prizm.cemetech.net/index.php?title=Debouncing_Multiple-Keypress_PRGM_GetKey
As a somewhat beginer C programmer also, I found that getting started was what was hardest. Sometimes the information is confusion becuase it is designed to be for more exprienced coders. Here... I will try to explain it a little bit easer.

Code:

//Double slashes are a single line comment.
//Start by including all your files you need. Such as:
include <colors.h>
//these are .h files (C header files)
//next include all of the defines
#define True=1
//wherever you have "True" it will be compiled as the value of 1
//Now include all of your global variables and functions you will be using. Global variables are variables that are open to use throughout the whole program.
int keydownlast(int basic_keycode);
// notice the "int" before the function name, this means that the variable (or value) that is returned after calling the function in of "integer" type.
int value=10
// variable "integer" named value now is equal to 10

int main() {
// C (and C++) use code blocks to structure your code, so the { denotes the beginning of a block and the } concludes it.
     int key;
     while(True) {
          Getkey(&key);
          // will continue untill a break statement
          // all of your code goes here
          if (keydownlast(KEY_PRGM_UP) && value==1) {
               // do this...
          }
     }
return 0;
}
//Functions go here!

Hopefully this helped.
zeldaking wrote:
As a somewhat beginer C programmer also, I found that getting started was what was hardest. Sometimes the information is confusion becuase it is designed to be for more exprienced coders. Here... I will try to explain it a little bit easer.


Don't forget the keyupdate() function in there Wink
I think it's easier to use a simple keydown function.
PierrotLL wrote:
I think it's easier to use a simple keydown function.


Indeed, depending on use. Unless you don't need the ability to debounce keys between frames, the predecessor "keydown" is a lot easier to use, Spence.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement