/* This file was generated by scramble.py. */
#line 1 "src/camera.py"
#include "camera.h"
#line 2
#include "game.h"
#line 8
Camera * camera_new(int w, int h) {
    Camera * self;
#line 9
    land_alloc(self);
    self->w = w;
    self->h = h;
    return self;
}
float camera_x(Camera * self, float px) {
    Game * game = game_global();
    float x = px - self->x;
    int mw = game->map->w * game->map->tw;
    if (x > mw / 2) {
#line 18
        x -= mw;
    }
#line 19
    if (x < - mw / 2) {
#line 19
        x += mw;
    }
#line 20
    return x;
}
float camera_y(Camera * self, float py) {
    Game * game = game_global();
    float y = py - self->y;
    int mh = game->map->h * game->map->th;
    if (y > mh / 2) {
#line 26
        y -= mh;
    }
#line 27
    if (y < - mh / 2) {
#line 27
        y += mh;
    }
#line 28
    return y;
}
/* This file was generated by scramble.py. */
