Something Different (Finally succeded?)

Talk about making games.

Something Different (Finally succeded?)

Postby Hblade » Thu Jan 12, 2012 8:52 pm

Here is something that might interest you. Its a redefinition of some things that could make things quicker or easier to read when scripting.
Code: Select all
              #define _TRUE_ 1
              #define _FALSE_ 0
              #define _ON_ 1
              #define _OFF_ 0

          #define Keyboard_0 key[KEY_0]
          #define Keyboard_1 key[KEY_1]
          #define Keyboard_2 key[KEY_2]
          #define Keyboard_3 key[KEY_3]
          #define Keyboard_4 key[KEY_4]
          #define Keyboard_5 key[KEY_5]
          #define Keyboard_6 key[KEY_6]
          #define Keyboard_7 key[KEY_7]
          #define Keyboard_8 key[KEY_8]
          #define Keyboard_9 key[KEY_9]
          #define Keyboard_A key[KEY_a]
          #define Keyboard_B key[KEY_b]
          #define Keyboard_C key[KEY_c]
          #define Keyboard_D key[KEY_d]
          #define Keyboard_E key[KEY_e]
          #define Keyboard_F key[KEY_f]
          #define Keyboard_G key[KEY_g]
          #define Keyboard_H key[KEY_h]
          #define Keyboard_I key[KEY_i]
          #define Keyboard_J key[KEY_j]
          #define Keyboard_K key[KEY_k]
          #define Keyboard_L key[KEY_l]
          #define Keyboard_M key[KEY_m]
          #define Keyboard_N key[KEY_n]
          #define Keyboard_O key[KEY_o]
          #define Keyboard_P key[KEY_p]
          #define Keyboard_Q key[KEY_q]
          #define Keyboard_R key[KEY_r]
          #define Keyboard_S key[KEY_s]
          #define Keyboard_T key[KEY_t]
          #define Keyboard_U key[KEY_u]
          #define Keyboard_V key[KEY_v]
          #define Keyboard_W key[KEY_w]
          #define Keyboard_X key[KEY_x]
          #define Keyboard_Y key[KEY_y]
          #define Keyboard_Z key[KEY_z]
          #define Keyboard_Backspace key[KEY_BACKSPACE]
          #define Keyboard_TAB key[KEY_TAB]
          #define Keyboard_Clear key[KEY_CLEAR]
          #define Keyboard_Return key[KEY_RETURN]
          #define Keyboard_Pause key[KEY_PAUSE]
          #define Keyboard_Esc key[KEY_ESCAPE]
          #define Keyboard_Space key[KEY_SPACE]
          #define Keyboard_LShift key[KEY_LSHIFT]
          #define Keyboard_RShift key[KEY_RSHIFT]
          #define Keyboard_LCtrl key[KEY_LCTRL]
          #define Keyboard_RCtrl key[KEY_RCTRL]
          #define Keyboard_LAlt key[KEY_LALT]
          #define Keyboard_RAlt key[KEY_RALT]
         
          #define Joystick_Right AXIS[0]>10000
          #define Joystick_Left AXIS[0]<-10000
          #define Joystick_Up AXIS[1]<-10000
          #define Joystick_Down AXIS[1]>10000
          #define Joystick_A_ON  BTN[0]==1
          #define Joystick_A_OFF BTN[0]==0
          #define Joystick_B_ON BTN[1]==1
          #define Joystick_B_OFF BTN[1]==0
          #define Joystick_X_ON BTN[2]==1
          #define Joystick_X_OFF BTN[2]==0
          #define Joystick_Y_ON BTN[3]==1
          #define Joystick_Y_OFF BTN[3]==0
          #define Joystick_LB_ON BTN[4]==1
          #define Joystick_LB_OFF BTN[4]==0
          #define Joystick_RB_ON BTN[5]==1
          #define Joystick_RB_OFF BTN[5]==0
          #define Joystick_Back_ON BTN[6]==1
          #define Joystick_Back_OFF BTN[6]==0
          #define Joystick_Start_ON BTN[7]==1
          #define Joystick_Start_OFF BTN[7]==0
          #define Joystick_L3_ON BTN[8]==1
          #define Joystick_L3_OFF BTN[8]==0
          #define Joystick_R3_ON BTN[9]==1
          #define Joystick_R3_OFF BTN[9]==0
         
int GLOBAL_INT[1000], BTN[10];
    double AXIS[2];
char *key;



void GetControl() {
    int i;
    key=GetKeyState();
    for(i=0;i<9;i++) {
        BTN[i]=GetJoystick1Button(i);
                     }
    AXIS[0]=GetJoystick1Axis(0);
    AXIS[1]=GetJoystick1Axis(1);
                  }


Let me explain how this works.

Keyboard_0 is the same as saying key[KEY_0] and it looks a lot neater. Example:
Code: Select all
if(Keyboard_0==1) {
    do code
}

versus
Code: Select all
if(key[KEY_0]==1) {
    do code
}




Some people might perfer the key[KEY_0] which is completely fine. I just wanted to make this for people who want to make things easier to read, and people who are beginners.


Usage:
Keyboard_0
Keyboard_1
Keyboard_2
Keyboard_3
Keyboard_4
Keyboard_5
Keyboard_6
Keyboard_7
Keyboard_8
Keyboard_9
Keyboard_Backspace
Keyboard_Space
Keyboard_LShift
Keyboard_RShift
Keyboard_LCtrl
Keyboard_RCtrl
Keyboard_LAlt
Keyboard_RAlt
Keyboard_TAB
Keyboard_Clear
Keyboard_Esc
Keyboard_Return
Keyboard_Pause
Keyboard_A
Keyboard_B
Keyboard_C
Keyboard_D
Keyboard_E
Keyboard_F
Keyboard_G
Keyboard_H
Keyboard_I
Keyboard_J
Keyboard_K
Keyboard_L
Keyboard_M
Keyboard_N
Keyboard_O
Keyboard_P
Keyboard_Q
Keyboard_R
Keyboard_S
Keyboard_T
Keyboard_U
Keyboard_V
Keyboard_W
Keyboard_X
Keyboard_Y
Keyboard_Z



This also comes with other useful stuff, and pre-designed for Joystick usage (Xbox styled controller)
Joystick_Button_ON
Joystick_Button_OFF

Replace Button with the button you'd like to have on or off.
A, B, X, Y, LB, RB, Back, Start, L3, R3.

Joystick_Right
Joystick_Left
Joystick_Up
Joystick_Down

All of these can be used to determine if the joystick is being pressed in a direction.



To use this, simply place
Code: Select all
GetControl();

in the draw actor of the person you want to enable these controls with.

GLOBAL_INT
This is an array of 999 total values. This can be used to create 999 variables without actually creating 999 variables by going to a fresh global code and putting something like this
#define VARNAME GLOBAL_INT[0]
Replace VARNAME with the variable name.

you already used 0 in that variable so you will get messed up if you use it again. In other words if you create another variable linking to that spot of the array.

_TRUE_
_FALSE_
_ON_
_OFF_
This can be used as well. TRUE and ON are set values of 1, while FALSE and OFF are 0.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Something Different (Finally succeded?)

Postby JamesLeonardo32 » Thu Jan 12, 2012 9:12 pm

Marvelous. This seems usefull.
JamesLeonardo32
 
Posts: 320
Joined: Wed Oct 13, 2010 4:57 pm
Score: 36 Give a positive score

Re: Something Different (Finally succeded?)

Postby Hblade » Fri Jan 13, 2012 3:22 am

Ty
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest