-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactored project name canvas->pixels
- Loading branch information
Jack Kelly
committed
Oct 19, 2018
1 parent
28e0edd
commit d19cf96
Showing
17 changed files
with
113 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
program: program.c | ||
gcc -Wall -o program program.c pixels/canvas.c pixels/screen.c pixels/draw.c -I/usr/include/SDL2 -D_REENTRANT -L/usr/lib/arm-linux-gnueabihf -lSDL2 | ||
|
||
1_pixel: 1_pixel.c | ||
gcc -Wall -o 1_pixel 1_pixel.c pixels/canvas.c pixels/screen.c pixels/draw.c -I/usr/include/SDL2 -D_REENTRANT -L/usr/lib/arm-linux-gnueabihf -lSDL2 | ||
|
||
2_line: 2_line.c | ||
gcc -Wall -o 2_line 2_line.c pixels/canvas.c pixels/screen.c pixels/draw.c -I/usr/include/SDL2 -D_REENTRANT -L/usr/lib/arm-linux-gnueabihf -lSDL2 | ||
|
||
3_box: 3_box.c | ||
gcc -Wall -o 3_box 3_box.c pixels/canvas.c pixels/screen.c pixels/draw.c -I/usr/include/SDL2 -D_REENTRANT -L/usr/lib/arm-linux-gnueabihf -lSDL2 | ||
|
||
4_splash: 4_splash.c | ||
gcc -Wall -o 4_splash 4_splash.c pixels/canvas.c pixels/screen.c pixels/draw.c -I/usr/include/SDL2 -D_REENTRANT -L/usr/lib/arm-linux-gnueabihf -lSDL2 | ||
|
||
5_rows: 5_rows.c | ||
gcc -Wall -o 5_rows 5_rows.c pixels/canvas.c pixels/screen.c pixels/draw.c -I/usr/include/SDL2 -D_REENTRANT -L/usr/lib/arm-linux-gnueabihf -lSDL2 | ||
|
||
6_avalanche: 6_avalanche.c | ||
gcc -Wall -o 6_avalanche 6_avalanche.c pixels/canvas.c pixels/screen.c pixels/draw.c -I/usr/include/SDL2 -D_REENTRANT -L/usr/lib/arm-linux-gnueabihf -lSDL2 | ||
|
||
clean: | ||
rm -f program 1_pixel 2_line 3_box 4_splash 5_rows 6_avalanche |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
#include <unistd.h> | ||
#include "SDL.h" | ||
|
||
#include "pixels/canvas.h" | ||
#include "pixels/screen.h" | ||
#include "pixels/draw.h" | ||
|
||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
int width = 32; | ||
int height = 32; | ||
|
||
canvas_create(width, height); | ||
|
||
screen_setup(width, height); | ||
|
||
/* ----- Write your program below ----- */ | ||
|
||
int frame = 0; | ||
bool ascending = true; | ||
|
||
bool exit = false; | ||
|
||
while (exit == false) | ||
{ | ||
if (screen_closebuttonpressed()) | ||
break; | ||
|
||
int x, y; | ||
|
||
for (y = 0; y < height; y++) | ||
for (x = 0; x < width; x++) | ||
{ | ||
Uint8 r = 255 - ((255 / height) * y); | ||
Uint8 g = (255 / width) * x; | ||
Uint8 b = frame % 255; | ||
|
||
draw_pixel(x, y, r, g, b); | ||
} | ||
|
||
if (frame >= 254) | ||
ascending = false; | ||
else if (frame <= 0) | ||
ascending = true; | ||
|
||
if (ascending == true) | ||
frame++; | ||
else | ||
frame--; | ||
|
||
screen_update(); | ||
usleep(16700); | ||
} | ||
|
||
/* ------------------------------------ */ | ||
|
||
screen_cleanup(); | ||
|
||
return 0; | ||
} |