need a lil help with this

Posted By: The_Unknown_Game

need a lil help with this - 01/30/10 04:00

EDIT: ok can anyone please show me how to use the up arrow on the keyboard so i can use the code in my game for a specific job
if any one can please leave a code sample that also explains what does what ty


Posted By: Redeemer

Re: need a lil help with this - 01/30/10 04:54

Wow! You have a lot of problems with your code here.

First, you should NEVER put a semicolon at the end of an "if" statement, like this:

Code:
if(select=0);



Or your code won't work. Period.

Also, the statement "select-50" is just an expression. It does not change the value of "select". To subtract 50 from "select", you have to type:

Code:
select -= 50;



There should not be any declaration for "key_cuu" in your script; that is handled automatically when you include "acknex.h"

Here's something else I should mention:

Code:
if(select = 0)
{
  select = 0;
}



This is redundant. This means: if select is 0, make it 0. Why do we need to do that? "select" is already 0 in case the "if" statement is true.

One last thing; if "select" is a panel pointer, you can't shift it up by subtracting 50 from it. For that, you have to type:

Code:
select.pos_y -= 50;


Posted By: The_Unknown_Game

Re: need a lil help with this - 01/30/10 05:06

ok let me ask this how do i use the up arrow in my code for it to do a specific job???
Posted By: testDummy

Re: need a lil help with this - 01/30/10 07:58

Code:
// sample function
void sample_fn() {
	while(1) {		// loop for-never
		if (key_cuu) {
			beep;	// <- specific job (unspecified) = beep
		}
		wait(1);	// wait one frame
	}
}

void main() {
	sample_fn();	// call sample function
}


Posted By: MrGuest

Re: need a lil help with this - 01/30/10 11:04

or just call the function when the key is pressed rather than making an event
Code:
void foo(){
   //do your do
   beep(); // beep once
   
   //or keep beeping
   while(key_cuu){
      beep();
      wait(1);
   }
}

void main(){
   on_cuu = foo();
}


Posted By: Joey

Re: need a lil help with this - 01/30/10 13:05

Code:
if(select=0)


is not a comparison, but an assignment, and will always evaluate to false.
© 2024 lite-C Forums