This commit is contained in:
/nick haya 2022-02-18 15:34:22 +08:00
parent dfb3f5e6bf
commit 0be41fede1
2 changed files with 24 additions and 1 deletions

View File

@ -50,6 +50,22 @@ class ExampleState : public sdfml::sdState {
example.y -= 1;
if (sdfml::key_pressed(SDL_SCANCODE_DOWN))
example.y += 1;
if (sdfml::key_pressed(SDL_SCANCODE_A))
sdfml::camera.x -= 1;
if (sdfml::key_pressed(SDL_SCANCODE_D))
sdfml::camera.x += 1;
if (sdfml::key_pressed(SDL_SCANCODE_W))
sdfml::camera.y -= 1;
if (sdfml::key_pressed(SDL_SCANCODE_S))
sdfml::camera.y += 1;
if (sdfml::key_pressed(SDL_SCANCODE_J))
sdfml::camera.zoom_x -= 0.1;
if (sdfml::key_pressed(SDL_SCANCODE_L))
sdfml::camera.zoom_x += 0.1;
if (sdfml::key_pressed(SDL_SCANCODE_K))
sdfml::camera.zoom_y -= 0.1;
if (sdfml::key_pressed(SDL_SCANCODE_I))
sdfml::camera.zoom_y += 0.1;
if (sdfml::key_just_pressed(SDL_SCANCODE_R))
sdfml::switchState(this);

View File

@ -192,16 +192,21 @@ namespace sdfml {
ShaderProg shader;
bool antialiasing = true;
virtual void create(int x, int y, string path) {
this->x = x;
this->y = y;
_tex_gpu = GPU_LoadImage(path.c_str());
SDL_Surface* temp_surf = STBIMG_Load(path.c_str());
_tex_gpu = GPU_CopyImageFromSurface(temp_surf);
GPU_SetBlendMode(_tex_gpu, GPU_BLEND_NORMAL);
_tex_gpu->is_alias = antialiasing;
width = _tex_gpu->w;
height = _tex_gpu->h;
color.r = 255;
color.g = 255;
color.b = 255;
SDL_FreeSurface(temp_surf);
}
virtual void addShader(std::string path) {
shader.loadShader(path, FRAGMENT, mContext.gpu_render, _tex_gpu);
@ -555,6 +560,8 @@ namespace sdfml {
SDL_Delay(floor((1000.0f/FRAMERATE) - elapsedMS));
GPU_SetCamera(mContext.gpu_render, &camera);
GPU_Flip(mContext.gpu_render);
}