Advertisement
Mr-A

A-Engine <object.h> v0.07

Aug 5th, 2014
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 11.21 KB | None | 0 0
  1. //==========Object.h===========
  2. #ifndef OBJECT_H_INCLUDED
  3. #define OBJECT_H_INCLUDED
  4.  
  5. //=================================
  6. // included dependencies
  7. #include "SDL.h"
  8. #include "SDL_image.h"
  9. //#include <GL/glext.h>
  10. #include "SDL_opengl.h"
  11. #include <string>
  12. #include <vector>
  13. #include <fstream>
  14. //=================================
  15.  
  16.  
  17. SDL_Color translate_color(Uint32 int_color);
  18.  
  19. struct Coord
  20. {
  21.     GLfloat x;
  22.     GLfloat y;
  23. };
  24.  
  25. struct LVertexData2D
  26. {
  27.     Coord position;
  28.     Coord texCoord;
  29. };
  30.  
  31. int GetPowerOf2(int num);
  32.  
  33. struct inputah
  34. {
  35.     int click;
  36.     int time;
  37. };
  38.  
  39. void DrawCircle(float cx, float cy, float r, int num_segments, float color[], int flag);
  40.  
  41. bool Collision_Occurs_Rect(int b[], int r[]);
  42.  
  43. class object;
  44.  
  45. struct objcopy
  46. {
  47.     int rectdensity[20]= {4321,4321,4321,4321,4321,4321,4321,4321,4321,4321,4321,4321,4321,4321,4321,4321,4321,4321,4321,4321};
  48.     std::string hit_xNO="0";
  49.     int inputarray[12]= {4321, 4321, 4321, 4321, 4321, 4321, 4321, 4321, 4321, 4321, 4321, 4321};
  50.     int hit_xINTERVAL=0;
  51.     int picn=999, gridn=0;
  52.     int id;
  53.     int delayU, nextframe, facing, U_loop_length, hitground;
  54.     float currhp=0, currsp=0, currrp=0, currdp, currkp;
  55.     int previousframe=4321;
  56.     bool showshadow=true;
  57.     bool deleted=false;
  58.     bool deleteobj=false;
  59.     float total_fx=0, total_fy=0, total_fz=0;
  60.     float GROUNDPOS=0;
  61.     bool jumpforward=false, isdead;
  62.     int doloop[2]= {0, 4321};
  63.     float posx , posy,  posz;
  64.     int team, currframe;
  65.     int lasthitby=4321;
  66.     bool caught=false;
  67.     int curse_id=4321;
  68.     int hitcounter=0;
  69.     bool iscom=false;
  70.     int movedirx, movedirz=2;
  71.     bool P_UP, P_DOWN, P_LEFT, P_RIGHT, P_ATTACK, P_DEFEND, P_JUMP, P_SPECIAL;
  72.     bool P_ATTACK_C=false, P_DEFEND_C=false, P_JUMP_C=false, P_SPECIAL_C=false, P_UP_C=false, P_DOWN_C=false, P_LEFT_C=false, P_RIGHT_C=false;
  73.     bool Tu=true, Td=true, Tl=true, Tr=true, TA=true, TJ=true, TD=true, TS=true;
  74.     int DshClksIntrvlR, DshClksIntrvlL, DASHL, DASHR=0;
  75.     bool newframe = true;
  76.     int accU=0;
  77.     float FRICTION;
  78.     float GRAVITY;
  79.     void init(object*, int, bool, float, float, int, int);
  80.     float ltstpltfrmvl=0.0;
  81.     int playerno=4321;
  82.     int regs[52]= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  83.     int index=4321;
  84.     int followerID=4321;
  85.     int onscreen_id;
  86.     int lasthit=4321;
  87.     bool newid=false;
  88.     int rndrbackid=4321;
  89.     int rndrngpriority=4321;
  90. };
  91.  
  92. objcopy copy_object(objcopy old_);
  93.  
  94. class LOAD;
  95.  
  96. class bdy
  97. {
  98. public:
  99.     std::string frameline;
  100.     bool exists;
  101.     int startpos;
  102.     int endpos;
  103.  
  104.     std::string x, y, z, w, h, z_w, block, respond, flg, rsstvty, inrt, bdgdp, reggy, reggyval, effreggy, effreggyval;
  105.     bdy();
  106.     void init(std::string);
  107. };
  108.  
  109. class rect
  110. {
  111. public:
  112.     std::string frameline;
  113.     bool exists;
  114.     int startpos;
  115.     int endpos;
  116.     bool flags[14]= {false, false, false, false, false, false, false, false, false, false, false, false, false, false};
  117.  
  118.     std::string x, y, z, w, h, z_w, damage, sccss, x_impct, y_impct, z_impct, hitfreq, effect, strength, knock, rmtid;
  119.     std::string tfgoto, tbgoto, t_x, t_y, t_z, crsid, rctdnsty, c_timer, effectf, flg, reggy, reggyval, tarreggy, tarreggyval;
  120.     std::string copysrc, copydst, trans[3];
  121.     rect();
  122.     void init(std::string);
  123. };
  124.  
  125. class combination
  126. {
  127. public:
  128.     bool exists;
  129.     std::string input,time_interval, delay, nxt, reggy, reggyval;;
  130.     int inputseq[6]= {4321, 4321, 4321, 4321, 4321, 4321}; //0-0:ca, 1:cd, 2:cj, 3:cs, 4:cf, 5:cb, 6:cu_a, 7:cd_a, 8:cl_a, 9:cr_a
  131.     //1-0:ha, 1:hd, 2:hj, 3:hs, 4:hf, 5:hb, 6:hu_a, 7:hd_a, 8:hl_a, 9:hr_a
  132.     int depth=0;
  133.     int startpos;
  134.     int endpos;
  135.     combination();
  136.     void init(std::string);
  137. };
  138.  
  139. class drawshape
  140. {
  141. public:
  142.     std::string frameline;
  143.     bool exists;
  144.     int startpos;
  145.     int endpos;
  146.     bool flags[4]= {false, false, false, false};
  147.     std::string x, y, w, h, x_r, y_r, strt_angle, arc_angle, border_width, vertices, cndtn,z,d,fill_color;
  148.     std::string color[4]= {"0", "0", "0", "0"}; //RGBA
  149.  
  150.     drawshape();
  151.     void init(std::string);
  152. };
  153.  
  154. class callobject
  155. {
  156. public:
  157.     std::string frameline;
  158.     bool exists;
  159.     int startpos;
  160.     int endpos;
  161.     bool flags[7]= {false, false, false, false, false, false, false};
  162.     std::string x, y, z, id, qntty, f_x, f_y, f_z, xhlddstnc, zhlddstnc, frm, delay, reggy, reggyval, cndtn;
  163.  
  164.     callobject();
  165.     void init(std::string);
  166. };
  167.  
  168. class frame
  169. {
  170.  
  171.     std::string frameline;
  172. public:
  173.     bool exists=false;
  174.     bool flags[23]= {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
  175.     bool menuflags[11]= {false, false, false, false, false, false, false, false, false, false, false};
  176.     int rectindx=0;
  177.     int bdyindx=0;
  178.     int combinationindx=0;
  179.     int callobjectindx=0;
  180.     int drawshapeindx=0;
  181.     std::vector<bdy> BDYS;
  182.     std::vector<rect> RECTS;
  183.     std::vector<combination> COMBINATIONS;
  184.     std::vector<callobject> CALLOBJECTS;
  185.     std::vector<drawshape> DRAWSHAPES;
  186.     std::string f, img, grid, delay, nxt, state, center_X, center_Y, f_x, f_y, f_z, loop_length, loop_goto, loop_condition, acc, alpha;
  187.     std::string zhlddstnc, xhlddstnc, zhldacc, xhldacc, mxlmtvx, mxlmtvy, mxlmtvz, counter, addhp, addsp, addrp, hitground, arrsstnc;
  188.     std::string c_a, c_j, c_d, c_s, c_b, c_f, c_ua, c_da, h_a, h_j, h_d, h_s, h_b, h_f, h_ua, h_da, c_ra, c_la, h_ra, h_la, nxtid;
  189.     std::string adptx, adpty, adptz;
  190.     std::string rndrngpriority, yacc;
  191.     std::string trans[3], reggy, reggyval;
  192.     int no;
  193.     void init(std::string, int);
  194. };
  195.  
  196. class spritegrid
  197. {
  198. public:
  199.     int w, h, col, row, frameno;
  200.     int gw, gh;
  201.     std::string colk;
  202.     //SDL_Surface *grid, *grid_;
  203.     //SDL_Texture *grid, *grid_;
  204.     GLuint grid;
  205.     GLuint shad;
  206.     int GetPowerOf2(int);
  207.     std::vector<SDL_Rect> clip;
  208.     std::vector<SDL_Rect> clip_;
  209.  
  210.     void ini(std::string dir_, int w_, int h_, int col_, int row_, std::string colk_, int * number, int filtering);
  211. };
  212.  
  213. class layer
  214. {
  215. public:
  216.     std::string img, x, y, rptx, rpty, prllxfctr, delay, restart, f_x, f_y;
  217.     int no, delayU=0;
  218.     int posx, posy;
  219.     int overalldelay=0;
  220.     bool flags[3]= {false, false, false};
  221.     bool exists=false;
  222.     std::vector<callobject> CALLOBJECTS;
  223.     std::vector<spritegrid> IMG;
  224.     int callobjectindx=0;
  225.  
  226.     void init(std::string, int);
  227. };
  228.  
  229. class background
  230. {
  231.     std::string name, bgcolor, arresstnc;
  232.  
  233. public:
  234.     LVertexData2D V_DATA [4];
  235.     GLuint I_DATA[4]= {0, 1, 2, 3};
  236.     GLuint VBO_ID, IBO_ID;
  237.     //SDL_Texture *backgroundTex;
  238.     //SDL_Texture *shadow;
  239.     std::vector<layer> LAYERS;
  240.     GLuint backgroundTex;
  241.     GLuint shadow;
  242.     SDL_Rect position;
  243.     SDL_Rect shadowpos;
  244.     int zbound, zboundwidth, xbound, xboundwidth, id;
  245.     float shadangx, shadangy;
  246.     void init (int, std::string, std::string);
  247.     void Blit(LOAD * LOADED);
  248. };
  249.  
  250. class object
  251. {
  252.  
  253. public:
  254.     LOAD*LOADED;
  255.     float wkspdxz_x,wkspdxz_z;
  256.     int wkspdx=0, wkspdz=0, frameno, w, h, facing=0, id, maxhp, maxsp, maxrp, inihp, inisp, inirp, delayU, nxt, currhp, currsp, currrp;
  257.     int rphit, rpsec, rpdam, sphit, spsec, spdam, armor, armorrate, walking, standing, fallingb, previousframe, U_loop_length, accU, falling, knockrate;
  258.     int jumping, jmpspdx, jmpspdz, hitground, whenhit, whenhitb, type, knocked, maxdp, dpsec, maxkp, lying, hittxtwidth, hitnowidth, fatigue, inair;
  259.     int height=0, width=0, allctfrms=650, allctimgs=10, spawn=1;
  260.     std::vector<frame> Frames;
  261.     std::vector<spritegrid> IMGS;
  262.     int spritecount=0, imgindx=0;
  263.  
  264.     std::string sprtfl, name, dpndncs, afildir;
  265.  
  266.     void init (int id, std::string dpndncs, std::string afildir);
  267.     int Eval(objcopy *objcop, std::string liny);
  268.     void Blit   (objcopy * objcop);
  269.     void CallObject(objcopy *);
  270.     void Walk(objcopy *objcop);
  271.     void Move (float value, char axis, objcopy * objcop);
  272.     void Update_Frame_If_Time(objcopy * objcop);
  273.     void Apply_loop(objcopy * objcop);
  274.     void Apply_f_x(objcopy * objcop);
  275.     void Apply_f_y(objcopy * objcop);
  276.     void Apply_f_z(objcopy * objcop);
  277.     void Apply_FRICTION(objcopy * objcop);
  278.     void Apply_GRAVITY(objcopy * objcop);
  279.     void Apply_acc(objcopy * objcop);
  280.     void Apply_x_z_hold_distance(objcopy * objcop);
  281.     void Apply_x_hold_distance(objcopy * objcop);
  282.     void Basic_Stand_Walk_Dash(objcopy * objcop);
  283.     void Apply_max_limit_vx(objcopy * objcop);
  284.     void Apply_max_limit_vy(objcopy * objcop);
  285.     void Basic_Jump(objcopy * objcop);
  286.     void BlitShadow(objcopy * objcop);
  287.     void Respond_ToInput(objcopy * objcop);
  288.     void Regenerate_Deplete_Stuff(objcopy * objcop);
  289.     void Set_IMG_No_On_Current_Grid(objcopy * objcop);
  290.     void CallObj(int paras[], bool flags[] );
  291.     void Platforming_Solid(objcopy * objcop, objcopy * target_objcop, int rect_index, int r[]);
  292.     void Collision_Related(objcopy * objcop, objcopy * target_objcop, int rect_index, int r[]);
  293.     void Adopt_Data(objcopy * objcop);
  294.     void Update(objcopy * objcop);
  295.     void LiteUpdate(objcopy * objcop);
  296.     void UpdateStat(objcopy * objcop);
  297.     void CheckCollision(objcopy * objcop);
  298.     void UpdateMove(objcopy * objcop);
  299. };
  300.  
  301. struct dataline
  302. {
  303.     int id;
  304.     std::string dependencies;
  305.     std::string directory;
  306.     int type;
  307. };
  308.  
  309. class LoadTxt
  310. {
  311. public:
  312.     std::vector<dataline> DATA_LINES;
  313.     int DATA_LINES_INDEX=0;
  314.     LoadTxt(std::string loadtxtdir);
  315.  
  316. };
  317.  
  318. class LOAD
  319. {
  320.     const char* LOAD_DIR;
  321.     const char* LOAD_TOKEN;
  322.     std::string line;
  323. public:
  324.     std::vector<std::vector<bool> > PKEYS;
  325.     int _playermenuorigins[20]= {0,0  ,0,0  ,0,0  ,0,0  ,0,0  ,0,0  ,0,0  ,0,0  ,0,0  ,0,0};
  326.     bool HITSYS=false;
  327.     int FPS;
  328.     std::vector<std::vector<int> > CATCHINGIDS; //0:framefront 1:frameback 2:x-pos 3:y-pos 4:z-pos 5:facing 6:timer
  329.     int DELETED_OBJS[1000];
  330.     int D_O_INDEX=0;
  331.     int GLOBALREGS[100];
  332.     int IDS[600];
  333.     int BGIDS[100];
  334.     int OBJSBEHIND[100];
  335.     int OBJSBEHIND_INDEX=0;
  336.     std::string settings[12]; //0-9 effects 10-gravity 11-friction
  337.     std::string BARS[19]= {"None", "None", "None", "", "", "", "", "", "", "", "", "", "None", "", "", "None", "None", "None", "None"};
  338.     std::vector<spritegrid> BARSG;
  339.     std::vector<objcopy*>  ON_SCREEN_OBJS;
  340.     std::vector<dataline> DATA_LINES;
  341.     //std::vector<objcopy*>  ON_SCREEN_OBJS_TO_BE_SORTED;
  342.     std::vector<objcopy>  ON_SCREEN_REAL_OBJS;
  343.     std::vector<objcopy> OBJS_STRUCTS;
  344.     std::vector<object>  OBJECTS;
  345.     std::vector<background> BACKGROUNDS;
  346.     int OBJID_INDEX;
  347.     int BGID_INDEX;
  348.     int CURRBG;
  349.     float FRICTION, GRAVITY;
  350.     int ON_SCREEN_OBJCOUNT=0;
  351.     void LoadSettigns_OnScreenObjs(void);
  352.     void LoadLOADTXTLite(void);
  353.     void initHeavy(std::string);
  354.     void initLite(void);
  355.     void LoadBG(std::string, int);
  356.     void LoadOBJ(std::string, int);
  357.     void CreateOBJECTCOPY(int, int, int, int);
  358.     void LoadObjsForGame(LoadTxt Txt, std::string objlines, int bgid, LOAD * LOADADDRESS);
  359.     int controllers[10]= {4321, 4321, 4321, 4321, 4321, 4321, 4321, 4321, 4321, 4321};
  360. };
  361.  
  362. #endif  // OBJECT_H_INCLUDED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement