Revision 332
worked out things
proj/include/ent.h | ||
---|---|---|
1 | 1 |
#ifndef ENT_H_INCLUDED |
2 | 2 |
#define ENT_H_INCLUDED |
3 | 3 |
|
4 |
#include "graph.h"
|
|
4 |
#include "basic_sprite.h"
|
|
5 | 5 |
#include "list.h" |
6 | 6 |
|
7 | 7 |
void (ent_set_scale) (double n); |
proj/libs/graph/include/graph.h | ||
---|---|---|
40 | 40 |
#define SET_BLU(n) (((n)&0xFF) ) |
41 | 41 |
#define SET_RGB(r,g,b) (SET_RED(r) | SET_GRE(g) | SET_BLU(b)) |
42 | 42 |
|
43 |
// PUBLIC GET |
|
43 |
/** |
|
44 |
* @brief Initialize graphics. |
|
45 |
* @param mode Graphics mode to use |
|
46 |
* @return SUCCESS if operation was successful, other value otherwise |
|
47 |
*/ |
|
48 |
int (graph_init)(uint16_t mode); |
|
49 |
|
|
50 |
/** |
|
51 |
* @brief Cleanup graphics. |
|
52 |
* @return SUCCESS if operation was successful, other value otherwise |
|
53 |
*/ |
|
54 |
int (graph_cleanup)(void); |
|
55 |
|
|
56 |
/** |
|
57 |
* @brief Get screen X-resolution. |
|
58 |
* @return Screen X-resolution |
|
59 |
*/ |
|
44 | 60 |
uint16_t (graph_get_XRes) (void); |
61 |
/** |
|
62 |
* @brief Get screen Y-resolution. |
|
63 |
* @return Screen Y-resolution |
|
64 |
*/ |
|
45 | 65 |
uint16_t (graph_get_YRes) (void); |
66 |
/** |
|
67 |
* @brief Get number of bytes per pixel. |
|
68 |
* |
|
69 |
* That is, the number of bytes needed to encode the color of a pixel. |
|
70 |
* @return Number of bytes per pixel |
|
71 |
*/ |
|
46 | 72 |
uint16_t (graph_get_bytes_pixel) (void); |
47 | 73 |
|
48 |
// INIT |
|
49 |
int (graph_init)(uint16_t mode); |
|
50 |
|
|
51 |
// CLEANUP |
|
52 |
int (graph_cleanup)(void); |
|
53 |
|
|
54 |
// PIXEL DRAWING |
|
55 |
int (graph_set_pixel) (uint16_t x, uint16_t y, uint32_t color); |
|
74 |
/** |
|
75 |
* @brief Draw pixel with color. |
|
76 |
* @param x X-position of pixel to draw |
|
77 |
* @param y Y-position of pixel to draw |
|
78 |
* @param color Color that will be used to draw the pixel |
|
79 |
* @return SUCCESS if operation was successful, other value otherwise |
|
80 |
*/ |
|
81 |
void (graph_set_pixel) (uint16_t x, uint16_t y, uint32_t color); |
|
82 |
/** |
|
83 |
* @brief Draw pixel with color using position. |
|
84 |
* |
|
85 |
* Position is calculated from y*WIDTH+x. |
|
86 |
* @param pos Position |
|
87 |
* @param color Color that will be used to draw the pixel |
|
88 |
*/ |
|
56 | 89 |
void (graph_set_pixel_pos) (unsigned pos , uint32_t color); |
57 | 90 |
|
58 | 91 |
// SCREEN |
proj/libs/graph/include/sprite.h | ||
---|---|---|
11 | 11 |
* @{ |
12 | 12 |
*/ |
13 | 13 |
|
14 |
#include "basic_sprite.h" |
|
15 |
|
|
14 | 16 |
struct sprite; |
15 | 17 |
typedef struct sprite sprite_t; |
16 | 18 |
|
proj/libs/graph/src/graph.c | ||
---|---|---|
256 | 256 |
} |
257 | 257 |
|
258 | 258 |
/// PIXEL DRAWING |
259 |
int (graph_set_pixel)(uint16_t x, uint16_t y, uint32_t color) { |
|
260 |
//pixels are certain to be inside can reduce lag |
|
261 |
/*if (x < 0 || vbe_mem_info.XResolution <= x || y < 0 || vbe_mem_info.YResolution <= y) { |
|
262 |
//printf("%s: invalid pixel.\n", __func__); |
|
263 |
return OUT_OF_RANGE; |
|
264 |
}*/ |
|
265 |
unsigned int pos = (x + y * vbe_mem_info.XResolution) * 3/*graph_get_bytes_pixel()*/; |
|
266 |
memcpy(video_buf + pos, &color, 3/*graph_get_bytes_pixel()*/); |
|
267 |
return SUCCESS; |
|
259 |
void (graph_set_pixel)(uint16_t x, uint16_t y, uint32_t color) { |
|
260 |
memcpy(video_buf + (x+y*graph_get_XRes())*graph_get_bytes_pixel(), &color, graph_get_bytes_pixel()); |
|
268 | 261 |
} |
269 | 262 |
void (graph_set_pixel_pos)(unsigned pos, uint32_t color){ |
270 | 263 |
memcpy(video_buf + pos, &color, graph_get_bytes_pixel()); |
... | ... | |
273 | 266 |
int (graph_draw)(void){ memcpy(video_mem, video_buf, graph_get_vram_size()); return SUCCESS; } |
274 | 267 |
|
275 | 268 |
///SPRITE |
269 |
#include "sprite.h" |
|
270 |
|
|
276 | 271 |
#include "utils.h" |
277 | 272 |
#include "fast_math.h" |
278 | 273 |
#include <math.h> |
proj/src/ent.c | ||
---|---|---|
3 | 3 |
#include "ent.h" |
4 | 4 |
|
5 | 5 |
#include "graph.h" |
6 |
#include "sprite.h" |
|
6 | 7 |
#include "utils.h" |
7 | 8 |
#include "rectangle.h" |
8 | 9 |
#include "font.h" |
proj/src/proj.c | ||
---|---|---|
18 | 18 |
#include "makecode_map.h" |
19 | 19 |
|
20 | 20 |
#include "graph.h" |
21 |
#include "sprite.h" |
|
21 | 22 |
#include "rectangle.h" |
22 | 23 |
#include "font.h" |
23 | 24 |
#include "ent.h" |
Also available in: Unified diff