SHARE
TWEET

Untitled

a guest Jan 12th, 2017 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class graphic::entity
  2. {
  3.     string alias;
  4.     string source;
  5.     vector source_size;
  6.     vector clip_origin;
  7.     vector clip_size;
  8.  
  9.     virtual void(vector location, vector scale, vector rgb, float alpha) Draw =
  10.     {
  11.         vector orig = [clip_origin_x, clip_origin_y];
  12.         vector ur = [clip_size_x + orig_x, orig_y];
  13.         vector lr = [ur_x, orig_y + clip_size_y];
  14.         vector ld = [orig_x, lr_y];
  15.         R_BeginPolygon(source, 0, 1);
  16.         R_PolygonVertex(location, ToTexCoords(source_size, orig), rgb, alpha);
  17.         R_PolygonVertex([location_x + (clip_size_x * scale_x), location_y] , ToTexCoords(clip_size, ur), rgb, alpha);
  18.         R_PolygonVertex([location_x + (clip_size_x * scale_x), location_y + (clip_size_y * scale_y)], ToTexCoords(clip_size, lr), rgb, alpha);
  19.         R_PolygonVertex([location_x, location_y + (clip_size_y * scale_y)], ToTexCoords(clip_size, ld), rgb, alpha);
  20.         R_EndPolygon();
  21.     };
  22. }
  23.  
  24. graphic *graphics;
  25. int graphics_count;
  26. hashtable graphics_table;
  27.  
  28. void(string _alias, string _source, vector _source_size, vector _clip_origin, vector _clip_size) Graphics_AddNew =
  29. {
  30.     if(graphics_count <= 0) graphics_table = hash_createtab(1, EV_INTEGER);
  31.     graphics_count++;
  32.     graphic *temp = memalloc(sizeof(graphic) * graphics_count);
  33.     memcpy(temp, graphics, sizeof(grapic) * (graphics_count - 1));
  34.     hash_add(graphics_table, graphics_count, EV_INTEGER);
  35.     graphics[graphics_count - 1] = spawn(graphics, alias:_alias, source:_source, source_size:_source_size, clip_origin:_clip_origin, clip_size:_clip_size);
  36. };
  37.  
  38. accessor gfx:graphic*
  39. {
  40.     get graphic* [string key] =
  41.     {
  42.         int index = hash_get(graphics_table, key);
  43.         return graphics + index;
  44.     }
  45. }Graphics
RAW Paste Data
Top