头文件structures.h
#ifndef STRUCTS_H
#define STRUCTS_H
#include "SDL2/SDL.h"
#include "DrawHelper.h"
extern int WIDTH,HEIGHT;
static SDL_Texture *pic;
static SDL_Surface *picSur;
class Point
{
public:
float x,y;
Point(float _x,float _y){
x=_x;y=_y;
}
Point(){
x=y=0;
}
Point operator=(Point toCopy)
{
x=toCopy.x;
y=toCopy.y;
return *this;
}
Point operator+(Point toAdd)
{
Point tmp;
tmp.x=x+toAdd.x;
tmp.y=y+toAdd.y;
return tmp;
}
Point operator-(Point toMinus)
{
Point tmp;
tmp.x=x-toMinus.x;
tmp.y=y-toMinus.y;
return tmp;
}
};
const int map_circle10[10][10]={
{0,0,85,255,255,255,255,85,0,0},
{0,170,255,255,255,255,255,255,170,0},
{85,255,255,255,255,255,255,255,255,85},
{255,255,255,255,255,255,255,255,255,255},
{255,255,255,255,255,255,255,255,255,255},
{255,255,255,255,255,255,255,255,255,255},
{255,255,255,255,255,255,255,255,255,255},
{85,255,255,255,255,255,255,255,255,85},
{0,170,255,255,255,255,255,255,170,0},
{0,0,85,255,255,255,255,85,0,0}
};
class circle
{
public:
static void draw(Point position,Uint8 r, Uint8 g, Uint8 b, Uint8 a, SDL_Surface* screen)
{
for(int dx=position.x;dx<position.x+10;dx++)
for(int dy=position.y;dy<position.y+10;dy++)
DrawHelper::setpixel(screen,dx,dy,r,g,b,map_circle10[dx][dy]);
}
static void draw(Point position, SDL_Renderer* renderer)
{
if(!picSur)
{
picSur=SDL_LoadBMP("assets/proj0.bmp");
pic = SDL_CreateTextureFromSurface(renderer, picSur);
}
DrawHelper::BiltTexture(position.x,position.y,pic,renderer);
}
};
#endif
2016年10月29日 11点10分
11