Skip to content

Commit 456ca22

Browse files
committed
program.c and minor changes
1 parent b145bd7 commit 456ca22

File tree

6 files changed

+27
-25
lines changed

6 files changed

+27
-25
lines changed

Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ exp: $(EXBINS)
1818

1919
%.math.e: %.math.c $(LIBA)
2020
@echo "Compiling example [m] $<"
21-
@$(CC) -o $@ $< $(CFLAGS) -L. -lm -lpluto
21+
@$(CC) -o $@ $< $(CFLAGS) -L. -lpluto -lm
2222

2323
%.e: %.c $(LIBA)
2424
@echo "Compiling example $<"
@@ -32,9 +32,9 @@ exp: $(EXBINS)
3232
@echo "Compiling object $<"
3333
@$(CC) $(LIBCFLAGS) -c $< -o $@
3434

35-
%.a: $(LIBOBJS)
36-
@echo "Generating $(LIBA)"
37-
@ar rcs $@ $(LIBOBJS)
35+
$(LIBA): $(LIBOBJS)
36+
@echo "Generating $@"
37+
@$(AR) rcs $@ $(LIBOBJS)
3838

3939
eclean:
4040
@$(RM) $(EXBINS)

README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@ Pre-compiled library files are available in the releases tab (only for Linux x86
3232
int main()
3333
{
3434
pluto_init_window(); /* Initialize pluto */
35-
pluto_save_screen(); /* Save screen (restored later) */
35+
pluto_save_screen(); /* Save screen */
3636
3737
for (;;)
3838
{
3939
for (int i = 0; i < _pluto_canvas.cheight; i++)
4040
{
41-
for (int j = 0; j < _pluto_canvas.cwidth; j++)
42-
{
43-
pluto_set_cpix(j, i, rand() % 256, rand() % 256, rand() % 256); /* Set pixel with random colours */
44-
}
41+
for (int j = 0; j < _pluto_canvas.cwidth; j++)
42+
{
43+
pluto_set_cpix(j, i, rand() % 256, rand() % 256, rand() % 256); /* Set pixel with random colours */
44+
}
4545
}
4646
47-
pluto_write_out(); /* Write to outbuffer */
48-
pluto_render(); /* Render the outbuffer */
47+
pluto_write_out(); /* Write to output buffer */
48+
pluto_render(); /* Render the output buffer */
4949
}
5050
5151
pluto_deinit();
@@ -74,9 +74,9 @@ Comments in the pluto.h file describe what each function/data structure does
7474
<p>A first person shooter using plutonem</p>
7575
<img src="screenshots/fps.png" align="center">
7676

77-
#### Plutonem is tested on:
77+
#### Plutonem is tested and works on:
7878
- [x] Operating systems: Linux, BSD, MacOS
79-
- [x] Terminal emulators: XTerm, Termite, Konsole, Alacritty and Kitty
79+
- [x] Terminal emulators: XTerm, Termite, Konsole, Alacritty (best performance) and Kitty
8080

8181
#### To-do
8282
- [x] RGB colours
@@ -85,7 +85,7 @@ Comments in the pluto.h file describe what each function/data structure does
8585

8686
#### Contributing:
8787
- Bug fixes
88-
- Small features (do not pull request a bunch of files together)
88+
- Features (don't pull request too many files at once)
8989
- Issue (GitHub issues tab) fixing
9090

9191
### Troubleshooting

examples/program.c

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
#include "../src/pluto.h"
22
#include <stdlib.h>
3+
#include <unistd.h>
34

45
int main()
56
{
67
pluto_init_window();
78

8-
for (int i = 1; i < _pluto_canvas.cheight; i++)
9+
for (int t = 0; t < 8; t++)
910
{
10-
for (int j = 1; j < _pluto_canvas.cwidth; j++)
11+
for (int i = 1; i < _pluto_canvas.cheight; i++)
1112
{
12-
if (i & j)
13-
pluto_set_cpix(j, i, i % 256, j % 256, i * j % 256);
13+
for (int j = 1; j < _pluto_canvas.cwidth; j++)
14+
{
15+
if ((j | i) & t)
16+
pluto_set_cpix(j % 256, i % 256, j % 256, i % 256, i * j % 256);
17+
}
1418
}
15-
}
1619

17-
pluto_write_out();
18-
pluto_render();
20+
pluto_write_out();
21+
pluto_render();
22+
usleep(350000);
23+
}
1924

2025
pluto_deinit();
2126
return 0;

src/drw.c

-2
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,3 @@ void pluto_set_ucpix(int x, int y, uint8_t red, uint8_t green, uint8_t blue)
9090
pluto_set_upix(x, y);
9191
pluto_set_upix_colour(x, y, red, green, blue);
9292
}
93-
94-
void pluto_sigwinch(int);

src/pluto.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,4 @@ extern void pluto_restore_screen();
144144
extern void pluto_resize();
145145
/* Updates the screen and canvas size */
146146

147-
#endif
147+
#endif /* pluto.h */

src/window.c

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
3939

4040
pluto_lib_t _pluto_canvas;
4141
void pluto_sigint(int);
42-
void pluto_sigwinch(int);
4342
extern void _pluto_unlock_term();
4443

4544
void pluto_save_screen()

0 commit comments

Comments
 (0)