File: tiles.cpp

package info (click to toggle)
supertransball2 1.5-6
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,336 kB
  • ctags: 477
  • sloc: cpp: 5,665; makefile: 45
file content (59 lines) | stat: -rw-r--r-- 902 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <stdio.h>
#include <stdlib.h>
#include "SDL/SDL.h"

#include "tiles.h"


TILE::TILE(SDL_Surface *src,int x,int y,int dx,int dy)
{
	orig=src;
	r.x=x;
	r.y=y;
	r.w=dx;
	r.h=dy;
} /* TILE */ 


TILE::~TILE()
{
} /* ~TILE */ 


void TILE::draw(int x,int y,SDL_Surface *surface)
{
	SDL_Rect d;

	d.x=x;
	d.y=y;
	SDL_BlitSurface(orig,&r,surface,&d);
} /* draw */ 


void TILE::draw_with_offset(int x,int y,SDL_Surface *surface,int offset)
{
	SDL_Rect o,d;

	if (offset>0 && offset<r.w) {
		o.x=r.x;
		o.y=r.y;
		o.w=r.w-offset;
		o.h=r.h;
		d.x=x+offset;
		d.y=y;
		SDL_BlitSurface(orig,&o,surface,&d);
	} /* if */ 
	if (offset==0) {
		draw(x,y,surface);
	} /* if */ 
	if (offset<0) {
		o.x=r.x-offset;
		o.y=r.y;
		o.w=r.w+offset;
		o.h=r.h;
		d.x=x;
		d.y=y;
		SDL_BlitSurface(orig,&o,surface,&d);
	} /* if */ 

} /* draw_with_offset */