The god damm programm wont crash anymore but still is crappy af

This commit is contained in:
Rohmer Maxime
2024-06-13 21:20:27 +02:00
parent e6c9b8d272
commit 99186c887b
14 changed files with 306 additions and 179 deletions
+14 -4
View File
@@ -14,6 +14,7 @@
#include "Background_image.h"
#include "testChart.h"
#include "Ship_1.h"
#include "Ship_3.h"
const int SCREEN_WIDTH = 240;
const int SCREEN_HEIGHT = 320;
@@ -253,7 +254,13 @@ void scroll(uint16_t scroll){
}
void Get_Color_From_Background(Point whereToLook,Color *color){
if(whereToLook.Y < 0)
whereToLook.Y = whereToLook.Y % SCREEN_HEIGHT;
int index = (whereToLook.Y*SCREEN_WIDTH+whereToLook.X)*3;
if(index < 0)
index = 1;
color->Red = SMPTE.pixel_data[index];
color->Green = SMPTE.pixel_data[index+1];
color->Blue = SMPTE.pixel_data[index+2];
@@ -301,12 +308,15 @@ void Refresh_Player_Area(Rectangle area,Rectangle Hitbox){
&& x + area.Position.X < Hitbox.Position.X + Hitbox.Size.Width){
Get_Color_From_Sprite(sprite,(Point){x-(Hitbox.Position.X - area.Position.X),y-(Hitbox.Position.Y-area.Position.Y)},&color);
SendPixel(color.Red,color.Green,color.Blue);
if(color.Red == 0 && color.Green == 0 && color.Blue == 0)
Get_Color_From_Background((Point){area.Position.X+x,(area.Position.Y+y)%SCREEN_HEIGHT},&color);
}else{
//Get_Color_From_Background((Point){area.Position.X+x,(area.Position.Y+y)%SCREEN_HEIGHT},&color);
//SendPixel(color.Red,color.Green,color.Blue);
SendPixel(0,0,0);
Get_Color_From_Background((Point){area.Position.X+x,(area.Position.Y+y)%SCREEN_HEIGHT},&color);
if(y == 0 || y == area.Size.Height -1 || x == 0 || x == area.Size.Width -1)
color = (Color){255,0,0};
}
SendPixel(color.Red,color.Green,color.Blue);
}
}
}
+2 -2
View File
@@ -3,14 +3,14 @@
/* GIMP RGB C-Source image dump (Ship_1.c) */
typedef struct Sprite_32x32_t{
const 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 = {
static 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"
+108
View File
@@ -0,0 +1,108 @@
#ifndef SPRITE_SHIP_3
#define SPRITE_SHIP_3
/* GIMP RGB C-Source image dump (Ship_3.c) */
static const struct {
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];
} Ship_3 = {
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\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\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\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\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\364\364\364\063<W\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\364\364\364Vl\206\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\364"
"\364\364\032\034,\063<W\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\364\364\364Vl\206\063<W\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\364\364\364"
"\032\034,\032\034,\063<W\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\364\364\364Vl\206\063<W\063<W\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\063<W\063"
"<W\032\034,\063<W\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\364\364\364Vl\206\063<WVl\206Vl\206\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\364\364\364\063<W\063<W\063"
"<W\063<W\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\364\364\364Vl\206Vl\206Vl\206Vl\206\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\364\364\364\063<W\063"
"<W\063<W\063<W\364\364\364\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364\063<WVl\206\364"
"\364\364\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364Vl\206Vl\206Vl\206Vl\206\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\364\364\364\032\034"
",\063<W\063<W\063<W\364\364\364\000\000\000\000\000\000\000\000\000\364\364\364\063<W;]\311A\246"
"\366Vl\206\364\364\364\000\000\000\000\000\000\000\000\000\364\364\364Vl\206Vl\206Vl\206\063"
"<W\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\364"
"\364\364\032\034,\032\034,\063<W\063<W\364\364\364\000\000\000\000\000\000\000\000\000\364\364\364"
"\063<WA\246\366s\357\367Vl\206\364\364\364\000\000\000\000\000\000\000\000\000\364\364\364V"
"l\206Vl\206\063<W\063<W\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\032\034,\364\364\364\032\034,\032\034,\063<W\364\364\364\000"
"\000\000\000\000\000\364\364\364\063<W;]\311A\246\366s\357\367A\246\366Vl\206\364\364"
"\364\000\000\000\000\000\000\364\364\364Vl\206\063<W\063<W\364\364\364\063<W\364\364\364"
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364\063<W\032\034,\364\364\364"
"\032\034,\032\034,\364\364\364\000\000\000\000\000\000\364\364\364\063<WA\246\366A\246\366"
"s\357\367s\357\367Vl\206\364\364\364\000\000\000\000\000\000\364\364\364\063<W\063<W\364"
"\364\364\063<WVl\206\364\364\364\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\364\364"
"\364\063<W\063<W\032\034,\364\364\364\032\034,\364\364\364\000\000\000\364\364\364\063"
"<W\063<WA\246\366\032\034,\063<Ws\357\367Vl\206Vl\206\364\364\364\000\000\000\364\364"
"\364\063<W\364\364\364\063<WVl\206Vl\206\364\364\364\000\000\000\000\000\000\000\000\000\000\000"
"\000\000\000\000\000\000\000\364\364\364\063<W\063<W\063<W\032\034,\364\364\364\364\364\364"
"\000\000\000\364\364\364\063<W\063<W;]\311\032\034,\063<WA\246\366Vl\206Vl\206\364\364"
"\364\000\000\000\364\364\364\364\364\364\063<WVl\206Vl\206Vl\206\364\364\364\000\000"
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364\063<W\032\034,\063<W\063<W\032\034"
",\364\364\364\000\000\000\364\364\364\063<W\063<W\063<W\032\034,\063<WVl\206Vl\206Vl"
"\206\364\364\364\000\000\000\364\364\364\063<WVl\206Vl\206\063<WVl\206\364\364\364"
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364\063<W\063<W\032\034,\063<W\063"
"<W\032\034,\364\364\364\364\364\364\063<W\063<W\063<W\032\034,\063<WVl\206Vl\206"
"Vl\206\364\364\364\364\364\364\063<WVl\206Vl\206\063<WVl\206Vl\206\364\364"
"\364\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364\063<W\063<W\063<W\063<W"
"\063<W\063<W\032\034,\364\364\364\063<W\063<W\063<W\032\034,\063<WVl\206Vl\206Vl\206"
"\364\364\364\063<WVl\206Vl\206Vl\206Vl\206Vl\206Vl\206\364\364\364\000\000\000\000"
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364\032\034,\063<W\063<W\063<W\032\034,\063"
"<W\063<W\032\034,\063<W\063<W\032\034,\032\034,\063<W\063<WVl\206Vl\206\063<WVl\206V"
"l\206\063<WVl\206Vl\206Vl\206\063<W\364\364\364\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,\063<W\063<W\063<W\032\034,\063<W\063<W\063<W\063"
"<W\032\034,\032\034,\063<W\063<WVl\206Vl\206Vl\206Vl\206\063<WVl\206Vl\206Vl\206"
"\063<W\063<W\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,\063<W\063<W\063<W\063<W\063<W\063<W\063<W\032\034,\032\034,\063<W"
"\063<WVl\206Vl\206Vl\206Vl\206Vl\206Vl\206Vl\206\063<W\063<W\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\032\034,\032"
"\034,\063<W\063<W\063<W\032\034,\063<W\063<W\032\034,\032\034,\063<W\063<WVl\206Vl\206"
"\063<WVl\206Vl\206Vl\206\063<W\063<W\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\364\364\364\032\034,\032\034,\063<W\063"
"<W\032\034,\063<W\032\034,\032\034,\032\034,\063<W\063<W\063<WVl\206\063<WVl\206Vl\206"
"\063<W\063<W\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\364\364\364\032\034,\032\034,\063<W\063<W\063<W\032"
"\034,\032\034,\032\034,\063<W\063<W\063<WVl\206Vl\206Vl\206\063<W\063<W\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\364\364\364\032\034,\032\034,\063<W\032\034,\032\034,\032\034,\032"
"\034,\063<W\063<W\063<W\063<WVl\206\063<W\063<W\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\364\364\364\032\034,\032\034,\032\034,\364\364\364\032\034,\364\364\364"
"\364\364\364\063<W\364\364\364\063<W\063<W\063<W\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\032\034,\032\034,\364\364\364\364\364"
"\364\000\000\000\000\000\000\364\364\364\364\364\364\063<W\063<W\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\364\364\364\032\034,\364\364\364"
"\000\000\000\000\000\000\000\000\000\000\000\000\364\364\364\063<W\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\364\364\364\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\000"
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
"\000\000\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\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",
};
#endif
+13 -5
View File
@@ -118,9 +118,15 @@ int min(int x,int y){
}
void RefreshPlayer(Point vector){
/*
if(vector.X != 0 || vector.Y != 0)
Refresh_Area(player.Hitbox);
*/
if(player.Hitbox.Position.Y + vector.Y < 0){
//player.Hitbox.Position.Y = SCREEN_SIZE.Height + (player.Hitbox.Position.Y - (0-vector.Y));
player.Hitbox.Position.Y = player.Hitbox.Position.Y & SCREEN_SIZE.Height;
player.Hitbox.Position.Y = SCREEN_SIZE.Height + (player.Hitbox.Position.Y - (0-vector.Y));
//player.Hitbox.Position.Y = player.Hitbox.Position.Y % SCREEN_SIZE.Height;
}else{
if(player.Hitbox.Position.Y + vector.Y >= SCREEN_SIZE.Height){
player.Hitbox.Position.Y = vector.Y - (SCREEN_SIZE.Height - player.Hitbox.Position.Y);
@@ -147,9 +153,11 @@ void RefreshPlayer(Point vector){
Refresh_Player_Area((Rectangle){bigPos,bigSize},player.Hitbox);
//Rectangle rect = player.Hitbox;
//rect.Position = (Point){0,0};
//DrawPlayer(player,rect);
/*
Rectangle rect = player.Hitbox;
rect.Position = (Point){0,0};
DrawPlayer(player,rect);
*/
}
int main(void) {