Browse Source

cleanup

main
Devine Lu Linvega 6 years ago
parent
commit
8300a33fca
  1. 30
      nasu.c
  2. BIN
      sprite.chr

30
nasu.c

@ -1,7 +1,7 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <stdio.h> #include <stdio.h>
#define HOR 16 #define HOR 32
#define VER 16 #define VER 16
#define PAD 8 #define PAD 8
#define ZOOM 4 #define ZOOM 4
@ -45,12 +45,16 @@ SDL_Renderer* gRenderer = NULL;
SDL_Texture* gTexture = NULL; SDL_Texture* gTexture = NULL;
uint32_t* pixels; uint32_t* pixels;
/* helpers */
int int
distance(int ax, int ay, int bx, int by) distance(int ax, int ay, int bx, int by)
{ {
return (bx - ax) * (bx - ax) + (by - ay) * (by - ay); return (bx - ax) * (bx - ax) + (by - ay) * (by - ay);
} }
/* chr */
int int
rowchr(int x, int y) rowchr(int x, int y)
{ {
@ -92,6 +96,14 @@ putchr(int x, int y, int color)
} }
} }
void
newchr(void)
{
int i;
for(i = 0; i < SZ; ++i)
chrbuf[i] = 0x00;
}
int int
jagg(int x, int y) jagg(int x, int y)
{ {
@ -163,6 +175,8 @@ line(int ax, int ay, int bx, int by, int color)
} }
} }
/* draw */
void void
draw(uint32_t* dst) draw(uint32_t* dst)
{ {
@ -201,6 +215,8 @@ update(Brush* b)
SDL_SetWindowTitle(gWindow, title); SDL_SetWindowTitle(gWindow, title);
} }
/* options */
int int
error(char* msg, const char* err) error(char* msg, const char* err)
{ {
@ -208,14 +224,6 @@ error(char* msg, const char* err)
return 0; return 0;
} }
void
create(void)
{
int i;
for(i = 0; i < SZ; ++i)
chrbuf[i] = 0x00;
}
void void
load(char* path) load(char* path)
{ {
@ -326,7 +334,7 @@ dokey(SDL_Event* event, Brush* b)
draw(pixels); draw(pixels);
break; break;
case SDLK_n: case SDLK_n:
create(); newchr();
break; break;
case SDLK_BACKQUOTE: case SDLK_BACKQUOTE:
b->mode = 7; b->mode = 7;
@ -414,7 +422,7 @@ main(int argc, char** argv)
if(argc > 1) if(argc > 1)
load(argv[1]); load(argv[1]);
else else
create(); newchr();
draw(pixels); draw(pixels);
update(&brush); update(&brush);

BIN
sprite.chr

Binary file not shown.
Loading…
Cancel
Save