Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class graphic::entity
- {
- string alias;
- string source;
- vector source_size;
- vector clip_origin;
- vector clip_size;
- virtual void(vector location, vector scale, vector rgb, float alpha) Draw =
- {
- vector orig = [clip_origin_x, clip_origin_y];
- vector ur = [clip_size_x + orig_x, orig_y];
- vector lr = [ur_x, orig_y + clip_size_y];
- vector ld = [orig_x, lr_y];
- R_BeginPolygon(source, 0, 1);
- R_PolygonVertex(location, ToTexCoords(source_size, orig), rgb, alpha);
- R_PolygonVertex([location_x + (clip_size_x * scale_x), location_y] , ToTexCoords(clip_size, ur), rgb, alpha);
- R_PolygonVertex([location_x + (clip_size_x * scale_x), location_y + (clip_size_y * scale_y)], ToTexCoords(clip_size, lr), rgb, alpha);
- R_PolygonVertex([location_x, location_y + (clip_size_y * scale_y)], ToTexCoords(clip_size, ld), rgb, alpha);
- R_EndPolygon();
- };
- }
- graphic *graphics;
- int graphics_count;
- hashtable graphics_table;
- void(string _alias, string _source, vector _source_size, vector _clip_origin, vector _clip_size) Graphics_AddNew =
- {
- if(graphics_count <= 0) graphics_table = hash_createtab(1, EV_INTEGER);
- graphics_count++;
- graphic *temp = memalloc(sizeof(graphic) * graphics_count);
- memcpy(temp, graphics, sizeof(grapic) * (graphics_count - 1));
- hash_add(graphics_table, graphics_count, EV_INTEGER);
- graphics[graphics_count - 1] = spawn(graphics, alias:_alias, source:_source, source_size:_source_size, clip_origin:_clip_origin, clip_size:_clip_size);
- };
- accessor gfx:graphic*
- {
- get graphic* [string key] =
- {
- int index = hash_get(graphics_table, key);
- return graphics + index;
- }
- }Graphics
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement