PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/src/SDLx/Controller/State.xs

http://github.com/PerlGameDev/SDL
Unknown | 99 lines | 85 code | 14 blank | 0 comment | 0 complexity | 6a455ad34887e7b785fcc7a8e1983e6b MD5 | raw file
 1#include "EXTERN.h"
 2#include "perl.h"
 3#include "XSUB.h"
 4#include "ppport.h"
 5#include "defines.h"
 6#include "helper.h"
 7
 8#ifndef aTHX_
 9#define aTHX_
10#endif
11
12#include "SDLx/Controller/Interface.h"
13
14
15MODULE = SDLx::Controller::State    PACKAGE = SDLx::Controller::State    PREFIX = state_
16
17SDLx_State *
18state_new( CLASS, ... )
19    char * CLASS
20    CODE:
21       RETVAL = (SDLx_State * ) safemalloc( sizeof(SDLx_State) );
22        if(items > 2)
23            RETVAL->x = SvIV(ST(2));
24        if(items > 3)
25            RETVAL->y = SvIV(ST(3));
26        if(items > 4)
27            RETVAL->v_x = SvIV(ST(4));
28        if(items > 5)
29            RETVAL->v_y = SvIV(ST(5));
30        if(items > 6)
31            RETVAL->rotation = SvIV(ST(6));
32        if(items > 7)
33            RETVAL->ang_v = SvIV(ST(7));
34    OUTPUT:
35	RETVAL 
36
37float
38state_x(state, ...)
39	SDLx_State * state
40	CODE:
41		if (items > 1 ) state->x = SvNV(ST(1)); 
42		RETVAL = state->x;
43	OUTPUT:
44		RETVAL
45
46float
47state_y(state, ...)
48	SDLx_State * state
49	CODE:
50		if (items > 1 ) state->y = SvNV(ST(1)); 
51		RETVAL = state->y;
52	OUTPUT:
53		RETVAL
54
55float
56state_v_x(state, ...)
57	SDLx_State * state
58	CODE:
59		if (items > 1 ) state->v_x = SvNV(ST(1));	
60		RETVAL = state->v_x;
61	OUTPUT:
62		RETVAL
63
64float
65state_v_y(state, ...)
66	SDLx_State * state
67	CODE:
68		if (items > 1 ) state->v_y = SvNV(ST(1));
69		RETVAL = state->v_y;
70	OUTPUT:
71		RETVAL
72
73float
74state_rotation(state, ...)
75	SDLx_State * state
76	CODE:
77		if (items > 1 ) state->rotation = SvNV((ST(1)));
78		RETVAL = state->rotation;
79	OUTPUT:
80		RETVAL
81
82float
83state_ang_v(state, ...)
84	SDLx_State * state
85	CODE:
86		if (items > 1 ) state->ang_v = SvNV((ST(1)));
87		RETVAL = state->ang_v;
88	OUTPUT:
89		RETVAL
90
91void
92state_DESTROY( bag )
93	SV *bag
94	CODE:
95		SDLx_State *obj = (SDLx_State *)bag2obj(bag);
96		if (obj->owned == 0)
97			objDESTROY(bag, safefree);
98
99