refactor file structure
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#include <dangerzone/engine.h>
|
||||
#include <dangerzone/render/misc.h>
|
||||
#include <dangerzone/render/rect.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* draws a rectangle with its left-top corner at (x,y) with
|
||||
* a width of 'w' and height of 'h' filled with color 'color'
|
||||
*/
|
||||
void
|
||||
put_rect(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t w,
|
||||
uint32_t h,
|
||||
uint32_t color
|
||||
) {
|
||||
for (int i = x; i < x + w; i++) {
|
||||
for (int j = y; j < y + h; j++) {
|
||||
put_pixel(i, j, color);
|
||||
}
|
||||
}
|
||||
mark_dirty_rect(x, y, w, h);
|
||||
}
|
||||
|
||||
void
|
||||
clear_rect(int x, int y, int w, int h, uint32_t color)
|
||||
{
|
||||
for (int py = y; py < y + h; ++py) {
|
||||
for (int px = x; px < x + w; ++px) {
|
||||
if (px >= 0 &&
|
||||
px < game_state->width &&
|
||||
py >= 0 &&
|
||||
py < game_state->height) {
|
||||
game_state->framebuffer[
|
||||
py * game_state->width + px
|
||||
] = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mark_dirty_rect(x, y, w, h);
|
||||
}
|
||||
Reference in New Issue
Block a user