Now there is a crappy sprite
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user