mirror of
https://github.com/Nimac0/SDL_Minigame
synced 2026-01-12 23:33:41 +00:00
Compare commits
No commits in common. "0179a27aafd9908de4057286150e8ede3088b8cd" and "a5c3ec36837b2aa58c2e1772de92629bd544ccbb" have entirely different histories.
0179a27aaf
...
a5c3ec3683
21
include/GameObject.h
Normal file
21
include/GameObject.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include <SDL.h>
|
||||
|
||||
class GameObject
|
||||
{
|
||||
public:
|
||||
GameObject(const char* texturesheet, int x, int y);
|
||||
~GameObject() = default;
|
||||
|
||||
void update();
|
||||
void render();
|
||||
|
||||
private:
|
||||
int xPos;
|
||||
int yPos;
|
||||
|
||||
SDL_Texture* objTexture;
|
||||
SDL_Rect srcRect;
|
||||
SDL_Rect destRect;
|
||||
};
|
||||
|
||||
36
src/GameObject.cpp
Normal file
36
src/GameObject.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
#include "GameObject.h"
|
||||
|
||||
#include "SDL_error.h"
|
||||
#include "TextureManager.h"
|
||||
#include "GameInternal.h"
|
||||
|
||||
GameObject::GameObject(const char* texturesheet, int x, int y)
|
||||
{
|
||||
// seems not to be used, and was using deprecated functionality
|
||||
SDL_SetError("GameObject not implemented");
|
||||
|
||||
this->xPos = x;
|
||||
this->yPos = y;
|
||||
}
|
||||
|
||||
void GameObject::update()
|
||||
{
|
||||
xPos++;
|
||||
yPos++;
|
||||
|
||||
srcRect.h = 32;
|
||||
srcRect.w = 32;
|
||||
srcRect.x = 0;
|
||||
srcRect.y = 0;
|
||||
|
||||
destRect.h = srcRect.h *2;
|
||||
destRect.w = srcRect.w *2;
|
||||
destRect.x = xPos;
|
||||
destRect.y = yPos;
|
||||
}
|
||||
|
||||
void GameObject::render()
|
||||
{
|
||||
SDL_SetError("GameObject not implemented");
|
||||
// SDL_RenderCopy(Game::renderer, objTexture, &srcRect, &destRect);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user