Now there is a crappy sprite
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#define SMPTE_H_
|
||||
/* GIMP RGB C-Source image dump (SMPTE_SIGNAL.c) */
|
||||
|
||||
static const struct {
|
||||
static const struct background_image_t{
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "fonts.h"
|
||||
#include "Background_image.h"
|
||||
#include "testChart.h"
|
||||
#include "Ship_1.h"
|
||||
|
||||
const int SCREEN_WIDTH = 240;
|
||||
const int SCREEN_HEIGHT = 320;
|
||||
@@ -257,22 +258,13 @@ void Get_Color_From_Background(Point whereToLook,Color *color){
|
||||
color->Green = SMPTE.pixel_data[index+1];
|
||||
color->Blue = SMPTE.pixel_data[index+2];
|
||||
}
|
||||
/*
|
||||
void Split_sprite(Rectangle area,Rectangle *first_half,Rectangle *second_half){
|
||||
if(area.Position.Y - area.Size.Height < 0){
|
||||
int diff = area.Position.Y - area.Size.Height < 0;
|
||||
Point secondAreaPosition = {area.Position.X,320};
|
||||
Size secondAreaSize = {area.Size.Width,diff};
|
||||
second_half->Position = secondAreaPosition;
|
||||
second_half->Size = secondAreaSize;
|
||||
Size oldAreaSize = {area.Size.Width,area.Size.Height + diff};
|
||||
first_half->Size.Height = oldAreaSize.Height;
|
||||
}else{
|
||||
first_half->Size = area.Size;
|
||||
first_half->Position = area.Position;
|
||||
}
|
||||
|
||||
void Get_Color_From_Sprite(Sprite_32x32 sprite, Point whereToLook, Color *color){
|
||||
int index = (whereToLook.Y*32+whereToLook.X)*3;
|
||||
color->Red = sprite.pixel_data[index];
|
||||
color->Green = sprite.pixel_data[index+1];
|
||||
color->Blue = sprite.pixel_data[index+2];
|
||||
}
|
||||
*/
|
||||
void auto_screen_roloff(Rectangle area,Point currentPos){
|
||||
if(currentPos.Y + area.Position.Y == SCREEN_HEIGHT){
|
||||
Point newPosition = {area.Position.X,0};
|
||||
@@ -295,13 +287,23 @@ void Refresh_Area(Rectangle area){
|
||||
}
|
||||
}
|
||||
}
|
||||
void DrawPlayer(Rectangle area){
|
||||
Resize_Window(area);
|
||||
void DrawPlayer(Player player, Rectangle areaToDraw){
|
||||
Sprite_32x32 sprite = ShipSprite1;
|
||||
Color color;
|
||||
Resize_Window(player.Hitbox);
|
||||
Write_Cmd(0x2C);
|
||||
for(int y = 0; y < area.Size.Height;y++){
|
||||
auto_screen_roloff(area,(Point){0,y});
|
||||
for(int x = 0; x < area.Size.Width+1;x++){
|
||||
SendPixel(0x58,0x2A,0x72);
|
||||
for(int y = 0; y < player.Hitbox.Size.Height;y++){
|
||||
auto_screen_roloff(player.Hitbox,(Point){0,y});
|
||||
for(int x = 0; x < (player.Hitbox.Size.Width+1);x++){
|
||||
if(y >= areaToDraw.Position.Y && y <= areaToDraw.Size.Height && x >= areaToDraw.Position.X && x <= areaToDraw.Size.Width){
|
||||
Get_Color_From_Sprite(sprite,(Point){x,y},&color);
|
||||
if(color.Red != 0 && color.Green != 0 && color.Blue != 0){
|
||||
SendPixel(color.Red,color.Green,color.Blue);
|
||||
}else{
|
||||
Get_Color_From_Background((Point){x+player.Hitbox.Position.X,(y+player.Hitbox.Position.Y)%SCREEN_HEIGHT},&color);
|
||||
SendPixel(color.Red,color.Green,color.Blue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,15 @@ typedef struct Rect_t{
|
||||
Size Size;
|
||||
}Rectangle;
|
||||
|
||||
typedef struct Player_t{
|
||||
Rectangle Hitbox;
|
||||
int HP;
|
||||
}Player;
|
||||
|
||||
void ILI9341_Initial(void);
|
||||
void Refresh_Area(Rectangle area);
|
||||
void Draw_stars();
|
||||
void Resize_Window(Rectangle area);
|
||||
void DrawPlayer(Player player, Rectangle areaToDraw);
|
||||
|
||||
#endif /* SPI_H_ */
|
||||
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
#ifndef SPRITE_SHIP_1
|
||||
#define SPRITE_SHIP_1
|
||||
|
||||
/* GIMP RGB C-Source image dump (Ship_1.c) */
|
||||
|
||||
typedef struct Sprite_32x32_t{
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */
|
||||
unsigned char pixel_data[32 * 32 * 3 + 1];
|
||||
}Sprite_32x32;
|
||||
|
||||
const Sprite_32x32 ShipSprite1 = {
|
||||
32, 32, 3,
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\364\364\364\364\364\364\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\364\364\364\032\034,)\066o\364\364\364\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\364\364\364\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364"
|
||||
"\032\034,\032\034,)\066o)\066o\364\364\364\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\364\364\364\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\364\364\364\364\364\364\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364"
|
||||
")\066o\032\034,;]\311A\246\366)\066o;]\311\364\364\364\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\364\364\364\364\364\364\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\364\364\364;]\311\364\364\364\000\000\000\000\000\000\000\000\000\364"
|
||||
"\364\364)\066o)\066o;]\311A\246\366s\357\367A\246\366;]\311;]\311\364\364\364"
|
||||
"\000\000\000\000\000\000\000\000\000\364\364\364A\246\366\364\364\364\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364;]\311;]\311\364\364\364"
|
||||
"\000\000\000\364\364\364)\066o)\066o;]\311A\246\366A\246\366s\357\367s\357\367A\246"
|
||||
"\366;]\311;]\311\364\364\364\000\000\000\364\364\364A\246\366A\246\366\364\364"
|
||||
"\364\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\364\364"
|
||||
"\364\032\034,;]\311\364\364\364\364\364\364)\066o)\066o;]\311A\246\366A\246\366"
|
||||
"A\246\366s\357\367s\357\367s\357\367A\246\366;]\311;]\311\364\364\364\364"
|
||||
"\364\364A\246\366)\066o\364\364\364\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\364\364\364)\066o\032\034,\364\364\364)\066o)\066o)\066"
|
||||
"oA\246\366A\246\366A\246\366A\246\366s\357\367s\357\367s\357\367s\357\367"
|
||||
";]\311;]\311;]\311\364\364\364)\066o;]\311\364\364\364\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364)\066o)\066o\364\364\364"
|
||||
")\066o)\066o)\066oA\246\366A\246\366A\246\366;]\311A\246\366s\357\367s\357\367"
|
||||
"s\357\367;]\311;]\311;]\311\364\364\364;]\311;]\311\364\364\364\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364)\066o)\066o"
|
||||
"\364\364\364)\066o)\066o)\066oA\246\366A\246\366;]\311\032\034,)\066oA\246\366"
|
||||
"s\357\367s\357\367;]\311;]\311;]\311\364\364\364;]\311;]\311\364\364\364"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364"
|
||||
")\066o)\066o\364\364\364)\066o)\066o)\066oA\246\366;]\311\032\034,\032\034,)\066o)"
|
||||
"\066oA\246\366s\357\367;]\311;]\311;]\311\364\364\364;]\311;]\311\364\364"
|
||||
"\364\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364\364"
|
||||
"\364\364)\066o)\066o\364\364\364)\066o)\066o)\066o;]\311)\066o\032\034,\032\034,)\066"
|
||||
"o)\066o;]\311A\246\366;]\311;]\311;]\311\364\364\364;]\311;]\311\364\364\364"
|
||||
"\364\364\364\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364)\066o\364"
|
||||
"\364\364)\066o)\066o)\066o)\066o)\066o)\066o)\066o)\066o\032\034,\032\034,)\066o)\066o"
|
||||
";]\311;]\311;]\311;]\311;]\311;]\311;]\311;]\311\364\364\364;]\311\364\364"
|
||||
"\364\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364)\066o)\066o\364\364\364)\066"
|
||||
"o)\066o)\066o)\066o)\066o)\066o)\066o)\066o\032\034,\032\034,)\066o)\066o;]\311;]\311"
|
||||
";]\311;]\311;]\311;]\311;]\311;]\311\364\364\364;]\311;]\311\364\364\364"
|
||||
"\000\000\000\000\000\000\000\000\000\364\364\364)\066o)\066o)\066o)\066o)\066o)\066o)\066o)\066o)\066"
|
||||
"o)\066o)\066o)\066o\032\034,\032\034,)\066o)\066o;]\311;]\311;]\311;]\311;]\311;]"
|
||||
"\311;]\311;]\311;]\311;]\311;]\311;]\311\364\364\364\000\000\000\364\364\364)\066"
|
||||
"o)\066o\032\034,)\066o)\066o)\066o)\066o)\066o\032\034,)\066o)\066o)\066o)\066o\032\034,"
|
||||
"\032\034,)\066o)\066o;]\311;]\311;]\311;]\311)\066o;]\311;]\311;]\311;]\311;]"
|
||||
"\311)\066o;]\311;]\311\364\364\364\364\364\364)\066o\032\034,\032\034,)\066o)\066"
|
||||
"o)\066o\032\034,)\066o)\066o)\066o)\066o)\066o)\066o\364\364\364\364\364\364\364\364"
|
||||
"\364\364\364\364;]\311;]\311;]\311;]\311;]\311;]\311)\066o;]\311;]\311;]\311"
|
||||
")\066o)\066o;]\311\364\364\364\364\364\364)\066o\032\034,\032\034,)\066o\032\034,)"
|
||||
"\066o)\066o)\066o)\066o)\066o)\066o\364\364\364\364\364\364\032\034,\032\034,\032\034"
|
||||
",\032\034,\364\364\364\364\364\364;]\311;]\311;]\311;]\311;]\311;]\311)\066"
|
||||
"o;]\311)\066o)\066o;]\311\364\364\364\364\364\364)\066o\032\034,)\066o)\066o)\066"
|
||||
"o)\066o)\066o)\066o)\066o\364\364\364\364\364\364\364\364\364)\066o\032\034,\032"
|
||||
"\034,\032\034,\032\034,)\066o\364\364\364\364\364\364\364\364\364;]\311;]\311;"
|
||||
"]\311;]\311;]\311;]\311;]\311)\066o;]\311\364\364\364\364\364\364)\066o)\066"
|
||||
"o)\066o)\066o)\066o)\066o)\066o\364\364\364\364\364\364\364\364\364\000\000\000\000\000"
|
||||
"\000\364\364\364)\066o\032\034,\032\034,)\066o\364\364\364\000\000\000\000\000\000\364\364\364"
|
||||
"\364\364\364\364\364\364;]\311;]\311;]\311;]\311;]\311;]\311;]\311\364\364"
|
||||
"\364\364\364\364)\066o)\066o)\066o)\066o)\066o\364\364\364\364\364\364\032\034,"
|
||||
"\032\034,\364\364\364\000\000\000\000\000\000\000\000\000\364\364\364)\066o)\066o\364\364\364\000"
|
||||
"\000\000\000\000\000\000\000\000\364\364\364)\066o)\066o\364\364\364\364\364\364;]\311;]\311"
|
||||
";]\311;]\311;]\311\364\364\364\364\364\364)\066o)\066o)\066o\364\364\364\364"
|
||||
"\364\364\364\364\364\032\034,)\066o)\066o\364\364\364\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\364\364\364\364\364\364\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364;]\311;]\311"
|
||||
")\066o\364\364\364\364\364\364\364\364\364;]\311;]\311;]\311\364\364\364\364"
|
||||
"\364\364)\066o\364\364\364\364\364\364\000\000\000\000\000\000\000\000\000\364\364\364)\066o"
|
||||
")\066o\364\364\364\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\364\364\364;]\311;]\311\364\364\364\000\000\000\000\000\000\000\000\000\364\364\364\364"
|
||||
"\364\364;]\311\364\364\364\364\364\364\364\364\364\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\364\364\364\364\364\364\364\364\364\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364\364\364\364\364\364\364"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364\364\364\364\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000",
|
||||
};
|
||||
#endif
|
||||
+11
-16
@@ -19,11 +19,6 @@ const Point SCREEN_ORIGIN = {0,0};
|
||||
const Size SCREEN_SIZE = {240,320};
|
||||
const Rectangle SCREEN = {SCREEN_ORIGIN,SCREEN_SIZE};
|
||||
|
||||
typedef struct Player_t{
|
||||
Rectangle Hitbox;
|
||||
int HP;
|
||||
}Player;
|
||||
|
||||
Player player;
|
||||
|
||||
void init(void)
|
||||
@@ -107,7 +102,7 @@ void scroll_array(int **array,int **newArray,int width,int height){
|
||||
|
||||
Player CreatePlayer(){
|
||||
int HP = 100;
|
||||
Size playerSize = {15,30};
|
||||
Size playerSize = {32,32};
|
||||
Point position = {SCREEN_SIZE.Width / 2 - playerSize.Width /2,SCREEN_SIZE.Height / 2 - playerSize.Height/2};
|
||||
Rectangle playerHitbox = {position,playerSize};
|
||||
Player player = {playerHitbox,HP};
|
||||
@@ -115,7 +110,7 @@ Player CreatePlayer(){
|
||||
}
|
||||
|
||||
void RefreshPlayer(Point vector){
|
||||
Refresh_Area(player.Hitbox);
|
||||
|
||||
|
||||
player.Hitbox.Position.X += vector.X;
|
||||
player.Hitbox.Position.Y += vector.Y;
|
||||
@@ -128,7 +123,11 @@ void RefreshPlayer(Point vector){
|
||||
if(player.Hitbox.Position.X < 0)
|
||||
player.Hitbox.Position.X = 0;
|
||||
|
||||
DrawPlayer(player.Hitbox);
|
||||
|
||||
Rectangle rect = player.Hitbox;
|
||||
rect.Position = (Point){0,0};
|
||||
DrawPlayer(player,rect);
|
||||
Refresh_Area(player.Hitbox);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
@@ -146,10 +145,9 @@ int main(void) {
|
||||
|
||||
while (true)
|
||||
{
|
||||
int JoystickState = JoystickGetState();
|
||||
|
||||
Point vec = {0,0};
|
||||
int increment = 1;
|
||||
int JoystickState = JoystickGetState();
|
||||
|
||||
if(JoystickState & (1 << 4)){
|
||||
vec.X -= increment;
|
||||
@@ -163,11 +161,6 @@ int main(void) {
|
||||
if(JoystickState & (1 << 1)){
|
||||
vec.Y -= increment;
|
||||
}
|
||||
if(JoystickState & 1){
|
||||
//empty
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(need_to_scroll){
|
||||
scroll(scrolling);
|
||||
@@ -185,7 +178,9 @@ int main(void) {
|
||||
Refresh_Area(areaToRefresh);
|
||||
DrawText(new_origin,newStr,charSize);
|
||||
}
|
||||
RefreshPlayer(vec);
|
||||
|
||||
if(need_to_scroll || vec.X != 0 || vec.Y != 0)
|
||||
RefreshPlayer(vec);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user