tornem a deixar els fitxers balloon.png com estaven

This commit is contained in:
JailDesigner committed 2024-07-30 12:02:15 +02:00
1 parent f4484b24f1
commit 884cacbc2e
33 files changed
+104 -336

No files matched your search

+17 -3
View File
@@ -2,15 +2,29 @@ frameWidth=10
frameHeight=10
[animation]
name=normal
name=orange
speed=10
loop=0
frames=0,1,2,3,4,5,6,7,8,9
[/animation]
[animation]
name=stopped
name=blue
speed=20
loop=0
frames=0,1,2,3,4,5,6,7,8,9
frames=10,11,12,13,14,15,16,17,18,19
[/animation]
[animation]
name=green
speed=10
loop=0
frames=20,21,22,23,24,25,26,27,28,29
[/animation]
[animation]
name=red
speed=20
loop=0
frames=30,31,32,33,34,35,36,37,38,39
[/animation]
Binary file not shown.

Before

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

+17 -3
View File
@@ -2,15 +2,29 @@ frameWidth=16
frameHeight=16
[animation]
name=normal
name=orange
speed=10
loop=0
frames=0,1,2,3,4,5,6,7,8,9
[/animation]
[animation]
name=stopped
name=blue
speed=20
loop=0
frames=0,1,2,3,4,5,6,7,8,9
frames=10,11,12,13,14,15,16,17,18,19
[/animation]
[animation]
name=green
speed=10
loop=0
frames=20,21,22,23,24,25,26,27,28,29
[/animation]
[animation]
name=red
speed=20
loop=0
frames=30,31,32,33,34,35,36,37,38,39
[/animation]
Binary file not shown.

Before

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

+17 -3
View File
@@ -2,15 +2,29 @@ frameWidth=26
frameHeight=26
[animation]
name=normal
name=orange
speed=10
loop=0
frames=0,1,2,3,4,5,6,7,8,9
[/animation]
[animation]
name=stopped
name=blue
speed=20
loop=0
frames=0,1,2,3,4,5,6,7,8,9
frames=10,11,12,13,14,15,16,17,18,19
[/animation]
[animation]
name=green
speed=10
loop=0
frames=20,21,22,23,24,25,26,27,28,29
[/animation]
[animation]
name=red
speed=20
loop=0
frames=30,31,32,33,34,35,36,37,38,39
[/animation]
Binary file not shown.

Before

Width:  |  Height:  |  Size: 908 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

+17 -3
View File
@@ -2,15 +2,29 @@ frameWidth=46
frameHeight=46
[animation]
name=normal
name=orange
speed=10
loop=0
frames=0,1,2,3,4,5,6,7,8,9
[/animation]
[animation]
name=stopped
name=blue
speed=20
loop=0
frames=0,1,2,3,4,5,6,7,8,9
frames=10,11,12,13,14,15,16,17,18,19
[/animation]
[animation]
name=green
speed=10
loop=0
frames=20,21,22,23,24,25,26,27,28,29
[/animation]
[animation]
name=red
speed=20
loop=0
frames=30,31,32,33,34,35,36,37,38,39
[/animation]
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 B

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

+1 -1
View File
@@ -2,7 +2,7 @@ frameWidth=46
frameHeight=46
[animation]
name=default
name=powerball
speed=10
loop=-1
frames=0
+6 -8
View File
@@ -317,14 +317,12 @@ void Balloon::render()
else if (isBeingCreated())
{
// Aplica alpha blending
//sprite->getTexture()->setPalette(1);
sprite->getTexture()->setAlpha(255 - (int)((float)creationCounter * (255.0f / (float)creationCounterIni)));
sprite->render();
sprite->getTexture()->setAlpha(255);
}
else
{
//sprite->getTexture()->setPalette(0);
sprite->render();
}
@@ -570,18 +568,18 @@ void Balloon::updateState()
// Establece la animación correspondiente al estado
void Balloon::updateAnimation()
{
std::string creatingAnimation = "stopped";
std::string normalAnimation = "normal";
std::string creatingAnimation = "blue";
std::string normalAnimation = "orange";
if (kind == POWER_BALL)
{
creatingAnimation = "default";
normalAnimation = "default";
creatingAnimation = "powerball";
normalAnimation = "powerball";
}
else if (getClass() == HEXAGON_CLASS)
{
creatingAnimation = "stopped";
normalAnimation = "normal";
creatingAnimation = "red";
normalAnimation = "green";
}
// Establece el frame de animación
+2 -1
View File
@@ -105,6 +105,7 @@ void uncompress( int code_length,
int stop_code; // one more than clear code
int match_len;
clear_code = 1 << ( code_length );
stop_code = clear_code + 1;
// To handle clear codes
@@ -141,7 +142,7 @@ void uncompress( int code_length,
{
code = 0x0;
// Always read one more bit than the code length
for ( i = 0; i < ( code_length + 1 ); i++ )
for ( i = 0; i < ( code_length + 1 ); ++i )
{
// This is different than in the file read example; that
// was a call to "next_bit"
-204
View File
@@ -1,204 +0,0 @@
#include "surface.h"
#include "gif.c"
struct jSurface_s
{
Uint8 *data;
Uint16 w, h;
};
// Constructor
Surface::Surface(const char *filename, jSurface dest)
{
surface = loadSurface(filename);
destSurface = dest;
texture = nullptr;
loadPalette(filename);
transparentColor = 0;
}
// Constructor
Surface::Surface(int width, int height, SDL_Texture *tex)
{
surface = newSurface(width, height);
destSurface = nullptr;
texture = tex;
clearPalette(0);
transparentColor = 0;
}
// Destructor
Surface::~Surface()
{
deleteSurface(surface);
deleteSurface(destSurface);
}
// Crea una surface
jSurface Surface::newSurface(int w, int h)
{
jSurface surf = (jSurface)malloc(sizeof(jSurface_s));
surf->w = w;
surf->h = h;
surf->data = (Uint8 *)malloc(w * h);
return surf;
}
// Borra una surface
void Surface::deleteSurface(jSurface surf)
{
if (surf == nullptr)
{
return;
}
if (surf->data != nullptr)
{
free(surf->data);
}
free(surf);
}
// Establece una surface de destino donde hacer el blit
void Surface::setDest(jSurface surf)
{
destSurface = surf;
}
// Establece una textura donde hacer el flip
void Surface::setTexture(SDL_Texture *tex)
{
texture = tex;
}
// Crea una surface a partir de un fichero .gif
jSurface Surface::loadSurface(const char *filename)
{
FILE *f = fopen(filename, "rb");
if (!f)
{
return nullptr;
}
fseek(f, 0, SEEK_END);
long size = ftell(f);
fseek(f, 0, SEEK_SET);
Uint8 *buffer = (Uint8 *)malloc(size);
fread(buffer, size, 1, f);
fclose(f);
Uint16 w, h;
Uint8 *pixels = LoadGif(buffer, &w, &h);
if (pixels == nullptr)
{
return nullptr;
}
jSurface surf = (jSurface)malloc(sizeof(jSurface_s));
surf->w = w;
surf->h = h;
surf->data = pixels;
free(buffer);
return surf;
}
// Carga una palette desde un fichero .gif
void Surface::loadPalette(const char *filename)
{
FILE *f = fopen(filename, "rb");
if (!f)
{
return;
}
fseek(f, 0, SEEK_END);
long size = ftell(f);
fseek(f, 0, SEEK_SET);
Uint8 *buffer = (Uint8 *)malloc(size);
fread(buffer, size, 1, f);
fclose(f);
Uint32 *pal = LoadPalette(buffer);
if (pal == nullptr)
{
return;
}
free(buffer);
for (int i = 0; i < 256; ++i)
{
palette[i] = pal[i];
}
}
// Cambia un color de la palette
void Surface::setPaletteColor(int index, Uint32 color)
{
palette[index] = color;
}
// Limpia la surface
void Surface::cls(Uint8 color)
{
for (int i = 0; i < surface->w * surface->h; ++i)
{
surface->data[i] = color;
}
}
// Volca la surface a una textura
void Surface::flip(SDL_Texture *texture)
{
Uint32 *pixels;
int pitch;
SDL_LockTexture(texture, nullptr, (void **)&pixels, &pitch);
for (int i = 0; i < surface->w * surface->h; ++i)
{
pixels[i] = palette[surface->data[i]];
}
SDL_UnlockTexture(texture);
}
// Escribe pixels en destSurface
void Surface::putPixel(int x, int y, Uint8 color)
{
// if (x < 0 || y < 0 || x >= jDestSurf->w || y >= jDestSurf->h || color == transparentColor)
if (x < 0 || y < 0 || x >= destSurface->w || y >= destSurface->h)
{
return;
}
destSurface->data[x + y * destSurface->w] = color;
}
// Lee pixels en surface
Uint8 Surface::getPixel(int x, int y)
{
return surface->data[x + y * surface->w];
}
// Copia pixels desde surface a destSurface
void Surface::blit(int dx, int dy, int sx, int sy, int w, int h)
{
if (surface == nullptr)
{
return;
}
for (int iy = 0; iy < h; ++iy)
{
for (int ix = 0; ix < w; ++ix)
{
putPixel(dx + ix, dy + iy, getPixel(sx + ix, sy + iy));
}
}
}
// Limpia la paleta
void Surface::clearPalette(Uint32 color)
{
for (int i = 0; i < 256; ++i)
{
palette[i] = color;
}
}
-63
View File
@@ -1,63 +0,0 @@
#pragma once
#include <SDL2/SDL.h>
typedef struct jSurface_s *jSurface;
class Surface
{
private:
// Variables
jSurface surface;
jSurface destSurface;
SDL_Texture *texture;
Uint32 palette[256];
int transparentColor;
// Escribe pixels en destSurface
void putPixel(int x, int y, Uint8 color);
// Lee pixels en surface
Uint8 getPixel(int x, int y);
// Limpia la paleta
void clearPalette(Uint32 color);
public:
// Constructor
Surface(const char *filename, jSurface dest);
Surface(int width, int height, SDL_Texture *tex);
// Destructor
~Surface();
// Crea una surface
jSurface newSurface(int w, int h);
// Borra una surface
void deleteSurface(jSurface surf);
// Establece una surface de destino donde hacer el blit
void setDest(jSurface surf);
// Establece una textura donde hacer el flip
void setTexture(SDL_Texture *tex);
// Crea una surface a partir de un fichero .gif
jSurface loadSurface(const char *filename);
// Carga una paleta desde un fichero .gif
void loadPalette(const char *filename);
// Copia pixels desde surface a destSurface
void blit(int dx, int dy, int sx, int sy, int w, int h);
// Cambia un color de la paleta
void setPaletteColor(int index, Uint32 color);
// Limpia la surface
void cls(Uint8 color);
// Volca la surface a una textura
void flip(SDL_Texture *texture);
};
+15 -17
View File
@@ -320,25 +320,24 @@ bool Director::setFileList()
asset->add(prefix + "/data/shaders/crtpi.glsl", t_data);
// Texturas
asset->add(prefix + "/data/gfx/balloon1.gif", t_bitmap);
asset->add(prefix + "/data/gfx/balloon1.png", t_bitmap);
asset->add(prefix + "/data/gfx/balloon1.ani", t_animation);
asset->add(prefix + "/data/gfx/balloon2.gif", t_bitmap);
asset->add(prefix + "/data/gfx/balloon2.png", t_bitmap);
asset->add(prefix + "/data/gfx/balloon2.ani", t_animation);
asset->add(prefix + "/data/gfx/balloon3.gif", t_bitmap);
asset->add(prefix + "/data/gfx/balloon3.png", t_bitmap);
asset->add(prefix + "/data/gfx/balloon3.ani", t_animation);
asset->add(prefix + "/data/gfx/balloon4.gif", t_bitmap);
asset->add(prefix + "/data/gfx/balloon4.png", t_bitmap);
asset->add(prefix + "/data/gfx/balloon4.ani", t_animation);
asset->add(prefix + "/data/gfx/balloon1_explosion.png", t_bitmap);
asset->add(prefix + "/data/gfx/balloon1_explosion.ani", t_animation);
asset->add(prefix + "/data/gfx/balloon2_explosion.png", t_bitmap);
asset->add(prefix + "/data/gfx/balloon2_explosion.ani", t_animation);
asset->add(prefix + "/data/gfx/balloon3_explosion.png", t_bitmap);
asset->add(prefix + "/data/gfx/balloon3_explosion.ani", t_animation);
asset->add(prefix + "/data/gfx/balloon4_explosion.png", t_bitmap);
asset->add(prefix + "/data/gfx/balloon4_explosion.ani", t_animation);
asset->add(prefix + "/data/gfx/balloon_blue_pal.gif", t_palette);
asset->add(prefix + "/data/gfx/balloon_yellow_pal.gif", t_palette);
asset->add(prefix + "/data/gfx/balloon_green_pal.gif", t_palette);
asset->add(prefix + "/data/gfx/explosion1.png", t_bitmap);
asset->add(prefix + "/data/gfx/explosion1.ani", t_animation);
asset->add(prefix + "/data/gfx/explosion2.png", t_bitmap);
asset->add(prefix + "/data/gfx/explosion2.ani", t_animation);
asset->add(prefix + "/data/gfx/explosion3.png", t_bitmap);
asset->add(prefix + "/data/gfx/explosion3.ani", t_animation);
asset->add(prefix + "/data/gfx/explosion4.png", t_bitmap);
asset->add(prefix + "/data/gfx/explosion4.ani", t_animation);
asset->add(prefix + "/data/gfx/powerball.png", t_bitmap);
asset->add(prefix + "/data/gfx/powerball.ani", t_animation);
@@ -353,11 +352,10 @@ bool Director::setFileList()
asset->add(prefix + "/data/gfx/game_text.png", t_bitmap);
asset->add(prefix + "/data/gfx/intro.png", t_bitmap);
asset->add(prefix + "/data/gfx/logo_jailgames.png", t_bitmap);
asset->add(prefix + "/data/gfx/logo_jailgames_mini.png", t_bitmap);
asset->add(prefix + "/data/gfx/logo_since_1998.png", t_bitmap);
asset->add(prefix + "/data/gfx/menu_game_over.png", t_bitmap);
asset->add(prefix + "/data/gfx/menu_game_over_end.png", t_bitmap);
asset->add(prefix + "/data/gfx/item_points1_disk.png", t_bitmap);
asset->add(prefix + "/data/gfx/item_points1_disk.ani", t_animation);
+12 -28
View File
@@ -331,48 +331,34 @@ void Game::loadMedia()
// Texturas
bulletTexture = new Texture(renderer, asset->get("bullet.png"));
gameTextTexture = new Texture(renderer, asset->get("game_text.png"));
gameOverTexture = new Texture(renderer, asset->get("menu_game_over.png"));
gameOverEndTexture = new Texture(renderer, asset->get("menu_game_over_end.png"));
// Texturas - Globos
Texture *balloon1Texture = new Texture(renderer, asset->get("balloon1.gif"));
balloon1Texture->addPalette(asset->get("balloon_blue_pal.gif"));
balloon1Texture->addPalette(asset->get("balloon_yellow_pal.gif"));
balloon1Texture->addPalette(asset->get("balloon_green_pal.gif"));
Texture *balloon1Texture = new Texture(renderer, asset->get("balloon1.png"));
balloonTextures.push_back(balloon1Texture);
Texture *balloon2Texture = new Texture(renderer, asset->get("balloon2.gif"));
balloon2Texture->addPalette(asset->get("balloon_blue_pal.gif"));
balloon2Texture->addPalette(asset->get("balloon_yellow_pal.gif"));
balloon2Texture->addPalette(asset->get("balloon_green_pal.gif"));
Texture *balloon2Texture = new Texture(renderer, asset->get("balloon2.png"));
balloonTextures.push_back(balloon2Texture);
Texture *balloon3Texture = new Texture(renderer, asset->get("balloon3.gif"));
balloon3Texture->addPalette(asset->get("balloon_blue_pal.gif"));
balloon3Texture->addPalette(asset->get("balloon_yellow_pal.gif"));
balloon3Texture->addPalette(asset->get("balloon_green_pal.gif"));
Texture *balloon3Texture = new Texture(renderer, asset->get("balloon3.png"));
balloonTextures.push_back(balloon3Texture);
Texture *balloon4Texture = new Texture(renderer, asset->get("balloon4.gif"));
balloon4Texture->addPalette(asset->get("balloon_blue_pal.gif"));
balloon4Texture->addPalette(asset->get("balloon_yellow_pal.gif"));
balloon4Texture->addPalette(asset->get("balloon_green_pal.gif"));
Texture *balloon4Texture = new Texture(renderer, asset->get("balloon4.png"));
balloonTextures.push_back(balloon4Texture);
Texture *balloon5Texture = new Texture(renderer, asset->get("powerball.png"));
balloonTextures.push_back(balloon5Texture);
// Texturas - Explosiones
Texture *explosion1Texture = new Texture(renderer, asset->get("balloon1_explosion.png"));
Texture *explosion1Texture = new Texture(renderer, asset->get("explosion1.png"));
explosionsTextures.push_back(explosion1Texture);
Texture *explosion2Texture = new Texture(renderer, asset->get("balloon2_explosion.png"));
Texture *explosion2Texture = new Texture(renderer, asset->get("explosion2.png"));
explosionsTextures.push_back(explosion2Texture);
Texture *explosion3Texture = new Texture(renderer, asset->get("balloon3_explosion.png"));
Texture *explosion3Texture = new Texture(renderer, asset->get("explosion3.png"));
explosionsTextures.push_back(explosion3Texture);
Texture *explosion4Texture = new Texture(renderer, asset->get("balloon4_explosion.png"));
Texture *explosion4Texture = new Texture(renderer, asset->get("explosion4.png"));
explosionsTextures.push_back(explosion4Texture);
// Texturas - Items
@@ -454,19 +440,19 @@ void Game::loadMedia()
// Animaciones -- Explosiones
std::vector<std::string> *explosions1Animation = new std::vector<std::string>;
loadAnimations(asset->get("balloon1_explosion.ani"), explosions1Animation);
loadAnimations(asset->get("explosion1.ani"), explosions1Animation);
explosionsAnimations.push_back(explosions1Animation);
std::vector<std::string> *explosions2Animation = new std::vector<std::string>;
loadAnimations(asset->get("balloon2_explosion.ani"), explosions2Animation);
loadAnimations(asset->get("explosion2.ani"), explosions2Animation);
explosionsAnimations.push_back(explosions2Animation);
std::vector<std::string> *explosions3Animation = new std::vector<std::string>;
loadAnimations(asset->get("balloon3_explosion.ani"), explosions3Animation);
loadAnimations(asset->get("explosion3.ani"), explosions3Animation);
explosionsAnimations.push_back(explosions3Animation);
std::vector<std::string> *explosions4Animation = new std::vector<std::string>;
loadAnimations(asset->get("balloon4_explosion.ani"), explosions4Animation);
loadAnimations(asset->get("explosion4.ani"), explosions4Animation);
explosionsAnimations.push_back(explosions4Animation);
// Animaciones -- Items
@@ -530,8 +516,6 @@ void Game::unloadMedia()
// Texturas
delete bulletTexture;
delete gameTextTexture;
delete gameOverTexture;
delete gameOverEndTexture;
for (auto texture : player1Textures)
{
-2
View File
@@ -101,8 +101,6 @@ private:
std::vector<std::vector<Texture *>> playerTextures; // Vector con todas las texturas de los jugadores;
Texture *gameTextTexture; // Textura para los sprites con textos
Texture *gameOverTexture; // Textura para la pantalla de game over
Texture *gameOverEndTexture; // Textura para la pantalla de game over de acabar el juego
std::vector<std::vector<std::string> *> itemAnimations; // Vector con las animaciones de los items
std::vector<std::vector<std::string> *> playerAnimations; // Vector con las animaciones del jugador