Project

General

Profile

Revision 286

many changes. added transparency to rectangles

View differences:

proj/include/sprite.h
1
#ifndef SPRITE_H_INCLUDED
2
#define SPRITE_H_INCLUDED
3

  
4

  
5

  
6
#endif //SPRITE_H_INCLUDED
7 0

  
proj/include/ent.h
1 1
#ifndef ENT_H_INCLUDED
2 2
#define ENT_H_INCLUDED
3 3

  
4
#include "sprite.h"
4
#include "graph.h"
5 5
#include "list.h"
6 6

  
7 7
void (ent_set_scale) (double n);
proj/libs/graph/include/rectangle.h
10 10
void (rectangle_set_pos)          (rectangle_t *p,  int16_t x,  int16_t y);
11 11
void (rectangle_set_size)         (rectangle_t *p, uint16_t w, uint16_t h);
12 12
void (rectangle_set_fill_color)   (rectangle_t *p, uint32_t color);
13
void (rectangle_set_fill_trans)   (rectangle_t *p, uint8_t  alpha);
13 14
void (rectangle_set_outline_color)(rectangle_t *p, uint32_t color);
14 15
void (rectangle_set_outline_width)(rectangle_t *p,  int16_t width);
15 16

  
proj/libs/graph/src/font.c
59 59
    size_t nchars;
60 60
    glyph_t **glyphs;
61 61
};
62
#include "sprite.h"
63
#include "rectangle.h"
62

  
64 63
font_t* (font_ctor)(const char *s){
65 64
    font_t *ret = malloc(sizeof(font_t));
66 65
    if(ret == NULL) return NULL;
proj/libs/graph/src/graph.c
278 278
int (graph_draw)(void){ memcpy(video_mem, video_buf, graph_get_vram_size()); return SUCCESS; }
279 279

  
280 280
///SPRITE
281
#include "sprite.h"
282

  
283 281
#include "utils.h"
284 282
#include "fast_math.h"
285 283
#include <math.h>
proj/libs/graph/src/rectangle.c
9 9
    int16_t  x, y;
10 10
    uint16_t w, h;
11 11
    uint32_t fill_color;
12
    uint8_t  fill_alpha;
12 13
    uint32_t outline_color;
13 14
    int16_t  outline_width;
14 15
};
......
21 22
    ret->w = w;
22 23
    ret->h = h;
23 24
    ret->fill_color    = 0xFFFFFF;
25
    ret->fill_alpha    = 0xFF;
24 26
    ret->outline_color = 0x000000;
25 27
    ret->outline_width = 0;
26 28
    return ret;
......
33 35
void (rectangle_set_pos)          (rectangle_t *p,  int16_t x,  int16_t y){ p->x = x; p->y = y; }
34 36
void (rectangle_set_size)         (rectangle_t *p, uint16_t w, uint16_t h){ p->w = w; p->h = h; }
35 37
void (rectangle_set_fill_color)   (rectangle_t *p, uint32_t color        ){ p->fill_color = color; }
38
void (rectangle_set_fill_trans)   (rectangle_t *p, uint8_t  alpha        ){ p->fill_alpha = alpha; }
36 39
void (rectangle_set_outline_color)(rectangle_t *p, uint32_t color        ){ p->outline_color = color; }
37 40
void (rectangle_set_outline_width)(rectangle_t *p,  int16_t width        ){ p->outline_width = width; }
38 41

  
......
52 55
        graph_set_pixel(x_, y, color);
53 56
    }
54 57
}
55

  
56 58
static void (rectangle_draw_vline)(int16_t x, int16_t y, int16_t l, uint32_t color){
57 59
    if(l < 0){ rectangle_draw_vline(x, y+l, -l, color); return; }
58 60
    for(int16_t y_ = max(0,y); y_ < min(y+l,graph_get_YRes()); ++y_){
......
61 63
}
62 64

  
63 65
void (rectangle_draw)(const rectangle_t *p){
64
    for(int16_t y = max(p->y,0); y < min(p->y+p->h, graph_get_YRes()); ++y)
65
        rectangle_draw_hline(p->x, y, p->w, p->fill_color);
66

  
66
    /// fill
67
    if(p->fill_alpha > ALPHA_THRESHOLD)
68
        for(int16_t y = max(p->y,0); y < min(p->y+p->h, graph_get_YRes()); ++y)
69
            rectangle_draw_hline(p->x, y, p->w, p->fill_color);
70
    /// border
67 71
    int16_t step = (p->outline_width > 0 ? 1 : -1);
68 72
    int16_t l = p->x, r = p->x+p->w, t = p->y, b = p->y+p->h;
69 73
    if(step > 0){
proj/libs/timer/src/timer.c
1 1
#include <lcom/lcf.h>
2 2

  
3 3
#include "timer.h"
4
#include "graph.h"
5
#include "sprite.h"
6 4

  
7 5
#define TIMER_FREQ     1193182                                                          /**< @brief clock frequency for timer in PC and AT */
8 6
#define TIMER_MIN_FREQ (TIMER_FREQ/UINT16_MAX) + ((TIMER_FREQ % UINT16_MAX) ? 1 : 0)    /**< @brief mininum frequency for timer */
proj/maps/map1.h
3 3

  
4 4
#include "map1.xpm"
5 5
#include "map1_collide.xpm"
6
#include "sprite.h"
6
#include "graph.h"
7 7

  
8 8
#include "xpm_utils.h"
9 9

  
proj/media/xpm/bullet.h
2 2
#define BULLET_H_INCLUDED
3 3

  
4 4
#include "bullet.xpm"
5
#include "sprite.h"
5
#include "graph.h"
6 6

  
7 7
basic_sprite_t* get_bullet(void){
8 8
    return basic_sprite_ctor((const char **)bullet_xpm, 3, 7);
proj/media/xpm/crosshair.h
1
#ifndef CROSSHAIR_H_INCLUDED
2
#define CROSSHAIR_H_INCLUDED
3

  
1 4
#include "crosshair.xpm"
2
#include "sprite.h"
5
#include "graph.h"
3 6

  
4 7
basic_sprite_t* get_crosshair(){
5 8
    return basic_sprite_ctor(crosshair_xpm, 16, 16);
6 9
}
10

  
11
#endif //CROSSHAIR_H_INCLUDED
proj/media/xpm/nothing.h
2 2
#define NOTHING_H_INCLUDED
3 3

  
4 4
#include "nothing.xpm"
5
#include "sprite.h"
5
#include "graph.h"
6 6

  
7 7
basic_sprite_t* get_nothing(void){
8 8
    return basic_sprite_ctor((const char **)nothing_xpm, 34, 34);
proj/media/xpm/pistol.h
2 2
#define PISTOL_H_INCLUDED
3 3

  
4 4
#include "pistol.xpm"
5
#include "sprite.h"
5
#include "graph.h"
6 6

  
7 7
basic_sprite_t* get_pistol(void){
8 8
    return basic_sprite_ctor((const char **)pistol_xpm, 34, 34);
proj/media/xpm/shooter.h
2 2
#define SHOOTER_H_INCLUDED
3 3

  
4 4
#include "shooter.xpm"
5
#include "sprite.h"
5
#include "graph.h"
6 6

  
7 7
basic_sprite_t* get_shooter(void){
8 8
    return basic_sprite_ctor((const char **)shooter_xpm, 34, 34);
proj/src/ent.c
3 3
#include "ent.h"
4 4

  
5 5
#include "graph.h"
6
#include "sprite.h"
7 6
#include "utils.h"
8 7
#include "rectangle.h"
9 8
#include <math.h>
proj/src/proj.c
17 17
#include "makecode_map.h"
18 18

  
19 19
#include "graph.h"
20
#include "sprite.h"
21 20
#include "rectangle.h"
22 21
#include "font.h"
23 22
#include "ent.h"

Also available in: Unified diff