Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include "SDL.h"
- #include <string.h>
- #include "drawline.h"
- #include "triangle.h"
- #include "object.h"
- // Create new object
- object_t *CreateObject(SDL_Surface *screen, triangle_t *model, int numtriangles)
- {
- object_t *object;
- object = (object_t *)malloc(sizeof(object_t));
- object->model = malloc(sizeof(triangle_t) * numtriangles);
- object->screen = screen;
- object->ttl = 5000;
- object->speedx = 1;
- object->speedy = 1;
- object->scale = 1;
- object->tx = 50;
- object->ty = 50;
- object->numtriangles = numtriangles;
- memcpy(object->model, model, sizeof(triangle_t) * numtriangles);
- return object;
- }
- // Free memory used by object
- void DestroyObject(object_t *object)
- {
- free(object->model);
- free(object);
- }
- // Draw object on screen
- void DrawObject(object_t *object)
- {
- int i;
- for (i = 0; i < object->numtriangles; i++){
- object->model[i].tx = object->tx;
- object->model[i].ty = object->ty;
- object->model[i].scale = object->scale;
- object->model[i].rotation = object->rotation;
- DrawTriangle (object->screen, &object->model[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement