From 07ae63f7412cbea5ae5d37001064f06ed18a1caa Mon Sep 17 00:00:00 2001 From: Fife Date: Thu, 9 Jun 2016 16:07:38 +0100 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20d'une=20nouvelle=20branche?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 0 CEngine.hpp | 91 ++ include/Components/Animation.hpp | 52 + include/Components/Render.hpp | 62 ++ include/Components/RigidBody.hpp | 50 + include/Components/Script.hpp | 39 + include/Components/Sprite.hpp | 54 ++ include/Components/Transform.hpp | 42 + include/Engine.hpp | 57 ++ include/Object.hpp | 64 ++ otherlib/FonctionC.c | 92 ++ otherlib/FonctionC.h | 11 + otherlib/MonochromeLib.c | 1559 ++++++++++++++++++++++++++++++ otherlib/MonochromeLib.h | 167 ++++ otherlib/input.c | 233 +++++ otherlib/input.h | 108 +++ src/Components/Animation.cpp | 118 +++ src/Components/Render.cpp | 146 +++ src/Components/RigiBodys.cpp | 216 +++++ src/Components/Script.cpp | 57 ++ src/Components/Sprite.cpp | 226 +++++ src/Components/Transforms.cpp | 66 ++ src/Engine.cpp | 196 ++++ src/Object.cpp | 162 ++++ 24 files changed, 3868 insertions(+) create mode 100644 .gitignore create mode 100644 CEngine.hpp create mode 100644 include/Components/Animation.hpp create mode 100644 include/Components/Render.hpp create mode 100644 include/Components/RigidBody.hpp create mode 100644 include/Components/Script.hpp create mode 100644 include/Components/Sprite.hpp create mode 100644 include/Components/Transform.hpp create mode 100644 include/Engine.hpp create mode 100644 include/Object.hpp create mode 100644 otherlib/FonctionC.c create mode 100644 otherlib/FonctionC.h create mode 100644 otherlib/MonochromeLib.c create mode 100644 otherlib/MonochromeLib.h create mode 100644 otherlib/input.c create mode 100644 otherlib/input.h create mode 100644 src/Components/Animation.cpp create mode 100644 src/Components/Render.cpp create mode 100644 src/Components/RigiBodys.cpp create mode 100644 src/Components/Script.cpp create mode 100644 src/Components/Sprite.cpp create mode 100644 src/Components/Transforms.cpp create mode 100644 src/Engine.cpp create mode 100644 src/Object.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/CEngine.hpp b/CEngine.hpp new file mode 100644 index 0000000..c612dff --- /dev/null +++ b/CEngine.hpp @@ -0,0 +1,91 @@ +/* ************************************************************************** */ +/* _____ */ +/* CEngine.hpp | ___| _ ____ ___ */ +/* Project : C-Engine | |_ | | | __| / _ \ */ +/* | _| | | | |= | __/ */ +/* By: Fife |_| |_| |_| \___| */ +/* */ +/* */ +/* ************************************************************************** */ + +#ifndef CENGINE_HPP +#define CENGINE_HPP + + extern "C" // Ajout des librairies externes au C-Engine + { + #include + #include + #include + #include + + #include "otherlib/input.h" + #include "otherlib/MonochromeLib.h" + #include "otherlib/FonctionC.h" + } + + #define rand_int(M) (rand() % (M)) + #define rand_int_ab(m, M) ((rand() % ((M) - (m)) + (m)) + #define abs(A) ((A) > 0 ? (A) : -(A)) + #define sgn(A) ((A) > 0 ? 1 : -1) + #define deg2rad(V) ((V) * 3.1415 / 180) + #define rad2deg(V) ((V) * 180 / 3.1415) + + //#define CE_ALL + #define CE_BASIC + //#define CE_RPG + //#define CE_PLATEFORME + //#define CE_NETWORK + + #ifdef CE_ALL + #define CE_BASIC + #define CE_RPG + #define CE_PLATEFORME + #define CE_NETWORK + #endif + + #ifdef CE_BASIC + + class Engine; + class Object; + + class Transform; + class RigidBody; + class Render; + class Animation; + class Sprite; + class Script; + + struct MassData + { + float mass; + float inv_mass; + }; + + struct Vec2 + { + double x; + double y; + }; + + struct Body + { + Transform * transform; + MassData mass_data; + Vec2 velocity; + Vec2 acceleration; + Vec2 force; + }; + + #include "include\Engine.hpp" + #include "include\Object.hpp" + + #include "include\Components\Transform.hpp" //Les composants de la class Object. + #include "include\Components\RigidBody.hpp" + #include "include\Components\Render.hpp" + #include "include\Components\Animation.hpp" + #include "include\Components\Sprite.hpp" + #include "include\Components\Script.hpp" + + #endif + +#endif /* CENGINE_HPP */ diff --git a/include/Components/Animation.hpp b/include/Components/Animation.hpp new file mode 100644 index 0000000..409f401 --- /dev/null +++ b/include/Components/Animation.hpp @@ -0,0 +1,52 @@ +/* ************************************************************************** */ +/* _____ */ +/* Animation.hpp | ___| _ ____ ___ */ +/* Project : C-Engine | |_ | | | __| / _ \ */ +/* | _| | | | |= | __/ */ +/* By: Fife |_| |_| |_| \___| */ +/* */ +/* */ +/* ************************************************************************** */ + +#ifndef CENGINE_ANIMATION_HPP +#define CENGINE_ANIMATION_HPP + +#include "..\Rework\CEngine.hpp" + + class Animation + { + public: + + Animation(); + Animation(Sprite & v); + Animation(Sprite * v , int nb , int nbd = 250 , bool vwaitatend = false , bool vwaittheend = false );//Constructeur + + void SetIt(int v); + + int GetSizeX(); + int GetSizeY(); + + int GetBlitX(); + int GetBlitY(); + + void DrawReverseAnim( int , int , int); + void DrawAnim( int , int , int ); + + bool WaitDelay(); + + private: + + Sprite * TabSprite; + + int iterateur; + int delay; // En ms + int time; + int nb_image; + + bool waitatend; + bool waittheend; + bool isend; + + }; + +#endif diff --git a/include/Components/Render.hpp b/include/Components/Render.hpp new file mode 100644 index 0000000..22bdeb6 --- /dev/null +++ b/include/Components/Render.hpp @@ -0,0 +1,62 @@ +/* ************************************************************************** */ +/* _____ */ +/* Render.hpp | ___| _ ____ ___ */ +/* Project : C-Engine | |_ | | | __| / _ \ */ +/* | _| | | | |= | __/ */ +/* By: Fife |_| |_| |_| \___| */ +/* */ +/* */ +/* ************************************************************************** */ + +#ifndef CENGINE_RENDER_HPP +#define CENGINE_RENDER_HPP + +#include "..\Rework\CEngine.hpp" + + class Render + { + public: + + Render(Object * Pointeur); //Constructeur + ~Render(); + + void SetRender(Animation * v, int nb); + void SetRender(Animation & v); + + void CopieRender(Animation * v, int nb); + void CopieRender(Animation & v); + + void SetIt( int v); + int GetIt(); + + void ReverseRender(bool); + bool GetReverse(); + + void SetDirection(int); + int GetDirection(); + + int GetSizeY(); + int GetSizeX(); + + int GetBlitX(); + int GetBlitY(); + + void DrawObject(); + + + private: + + Object * Conteneur; + Animation * TabAnim; + + int nb_anim; + int iterateur; + int time; + + int direction; + bool reverse; + + bool copie; + }; + +#endif diff --git a/include/Components/RigidBody.hpp b/include/Components/RigidBody.hpp new file mode 100644 index 0000000..3079586 --- /dev/null +++ b/include/Components/RigidBody.hpp @@ -0,0 +1,50 @@ +/* ************************************************************************** */ +/* _____ */ +/* RigidBody.hpp | ___| _ ____ ___ */ +/* Project : C-Engine | |_ | | | __| / _ \ */ +/* | _| | | | |= | __/ */ +/* By: Fife |_| |_| |_| \___| */ +/* */ +/* */ +/* ************************************************************************** */ + +#ifndef CENGINE_RIGIDBODY_HPP +#define CENGINE_RIGIDBODY_HPP + +#include "..\Rework\CEngine.hpp" + + class RigidBody + { + public: + + RigidBody(Object * Pointeur); //Constructeur + + void SetMass(float); + void UseFixeBody( int w , int h); + void UseFlexBody(); + + void AppliedForce(); + + int Move( int x , int y); + int TryMove( int x , int y); + int CollisionDecor( int x , int y); + void Affine(int vx , int vy); + + int GetWidht(); + int GetHeight(); + bool GetStat(); + + Body * GetBody(); + + private: + + Object * Conteneur; + + Body R_body; + + bool usefixebody; + int widht; + int height; + }; + +#endif diff --git a/include/Components/Script.hpp b/include/Components/Script.hpp new file mode 100644 index 0000000..55e6d92 --- /dev/null +++ b/include/Components/Script.hpp @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* _____ */ +/* Script.hpp | ___| _ ____ ___ */ +/* Project : C-Engine | |_ | | | __| / _ \ */ +/* | _| | | | |= | __/ */ +/* By: Fife |_| |_| |_| \___| */ +/* */ +/* */ +/* ************************************************************************** */ + +#ifndef CENGINE_SCRIPT_HPP +#define CENGINE_SCRIPT_HPP + +#include "..\Rework\CEngine.hpp" + + class Script + { + public: + + Script(); //Constructeur + + virtual void Update(); + virtual void UpdateEverySecond(); + virtual void Start(); + + void AffectObject(Object * OV); + void AffectEngine(Engine * EV); + + Engine * GetEngine(); + Object * GetObject(); + + private: + + Object * OConteneur; + Engine * EConteneur; + + }; + +#endif diff --git a/include/Components/Sprite.hpp b/include/Components/Sprite.hpp new file mode 100644 index 0000000..ad8f1a3 --- /dev/null +++ b/include/Components/Sprite.hpp @@ -0,0 +1,54 @@ +/* ************************************************************************** */ +/* _____ */ +/* Sprite.hpp | ___| _ ____ ___ */ +/* Project : C-Engine | |_ | | | __| / _ \ */ +/* | _| | | | |= | __/ */ +/* By: Fife |_| |_| |_| \___| */ +/* */ +/* */ +/* ************************************************************************** */ + +#ifndef CENGINE_SPRITE_HPP +#define CENGINE_SPRITE_HPP + +#include "..\Rework\CEngine.hpp" + + class Sprite + { + public: + + Sprite(); + Sprite(const unsigned char * v1 , int sizex , int sizey , int bx = 0 , int by = 0 ); + Sprite(const unsigned char * v1 , const unsigned char * v2 , int sizex , int sizey , int bx = 0 , int by = 0 ); //Constructeur + + void DrawReverseSprite( int x , int y , int d ); + void DrawSprite( int x , int y , int d ); + + void CreateReverse( int brx = 0 , int bry = 0 ); + + int GetSizeY(); + int GetSizeX(); + + int GetBlitX(); + int GetBlitY(); + + private: + + const unsigned char * Beta; + const unsigned char * Alpha; + + unsigned char * ReverseBeta; + unsigned char * ReverseAlpha; + + int size_x; + int size_y; + + int b_x; + int b_y; + + int br_x; + int br_y; + + }; + +#endif diff --git a/include/Components/Transform.hpp b/include/Components/Transform.hpp new file mode 100644 index 0000000..597b9bb --- /dev/null +++ b/include/Components/Transform.hpp @@ -0,0 +1,42 @@ +/* ************************************************************************** */ +/* _____ */ +/* Transform.hpp | ___| _ ____ ___ */ +/* Project : C-Engine | |_ | | | __| / _ \ */ +/* | _| | | | |= | __/ */ +/* By: Fife |_| |_| |_| \___| */ +/* */ +/* */ +/* ************************************************************************** */ + +#ifndef CENGINE_TRANSFORM_HPP +#define CENGINE_TRANSFORM_HPP + +#include "..\Rework\CEngine.hpp" + + class Transform + { + public: + + Transform(Object * Pointeur); //Constructeur + + double GetX(); + double GetY(); + + double GetRelativeX(); + double GetRelativeY(); + + void SetX(double v); + void SetY(double v); + void SetXY(double vx ,double vy); + + void SetRelativeXY(double vx ,double vy); + + private: + + Object * Conteneur; + + Vec2 positionabsolu; // en pixel + Vec2 positionrelative; // en pixel + }; + +#endif diff --git a/include/Engine.hpp b/include/Engine.hpp new file mode 100644 index 0000000..4d1384d --- /dev/null +++ b/include/Engine.hpp @@ -0,0 +1,57 @@ +/* ************************************************************************** */ +/* _____ */ +/* Engine.hpp | ___| _ ____ ___ */ +/* Project : C-Engine | |_ | | | __| / _ \ */ +/* | _| | | | |= | __/ */ +/* By: Fife |_| |_| |_| \___| */ +/* */ +/* */ +/* ************************************************************************** */ + +#ifndef CENGINE_ENGINE_HPP +#define CENGINE_ENGINE_HPP + +#include "..\Rework\CEngine.hpp" + + class Engine + { + public: + + Engine(); //Constructeur + + void StartGame(); //Lance le jeu + void InitGame(); //Initialise le jeu + void StopGame(); //Quitte le jeu + + void ShowFps(); //Affiche les FPS à l'écran + void HideFps(); //Cache les FPS de l'écran + void SetFpsWish(int v); //Set le nombre de FPS + + void AddObject( Object * v); //Ajout un objet au moteur + void DelObject( Object * v); //Supprime l'objet + void DelAllObject(); //Supprime tout les objets + + Object ** GetListeObject(); //Renvoie un pointeur sur le tableau d'objet + int GetNbObject(); //Renvoie le nombre d'objet liés au moteur + + void ExecuteScript(); + void AppliedForce(); + void Draw(); + + void UpdateRelativePosition(); + + private: + + bool execute; + + int fpswish; + bool fps; + + Object ** listeObject; //Tableau d'objet utilisé dans le cas ou il n'y a pas de map. + int nbobject; //Nombre d'objet liés au moteur. nb = Nombre + + + + }; + +#endif diff --git a/include/Object.hpp b/include/Object.hpp new file mode 100644 index 0000000..b5dfb71 --- /dev/null +++ b/include/Object.hpp @@ -0,0 +1,64 @@ +/* ************************************************************************** */ +/* _____ */ +/* Object.hpp | ___| _ ____ ___ */ +/* Project : C-Engine | |_ | | | __| / _ \ */ +/* | _| | | | |= | __/ */ +/* By: Fife |_| |_| |_| \___| */ +/* */ +/* */ +/* ************************************************************************** */ + +#ifndef CENGINE_OBJECT_HPP +#define CENGINE_OBJECT_HPP + +#include "..\Rework\CEngine.hpp" + + class Object + { + public: + + Object(); //Constructeur + ~Object(); + + void AffectEngine(Engine * EV); + void AffectTag(char * v); + + void Enable(); + void Disable(); + + void AddRigidBody(); //Ajout un RigidBody + + //Accesseur + + Engine * GetEngine(); + Transform * GetTransform(); + RigidBody * GetRigidBody(); + Render * GetRender(); + Script * GetScript(); + + char * GetTag(); + bool GetEnable(); + + //Fonction pour les scripts + + Object * GetObjectCollisionTag( char* v , int x = 0 , int y = 0); + bool GetCollisionTag( char * v , int x = 0 , int y = 0 ); + + bool IsOnScreen(); + + private: + + bool Collision(int id); + + Transform * OTransform; + Render * ORender; + RigidBody * ORigidBody; + Script * OScript; + Engine * Conteneur; + + char * tag; + bool enable; + + }; + +#endif diff --git a/otherlib/FonctionC.c b/otherlib/FonctionC.c new file mode 100644 index 0000000..30875e9 --- /dev/null +++ b/otherlib/FonctionC.c @@ -0,0 +1,92 @@ +#include "MonochromeLib.h" +#include +#include +#include +#include "FonctionC.h" + +PrintV(int x, int y, int v) +{ + char txt[10]; + sprintf(txt,"%d",v); + PrintMini(x,y,txt,0); +} + +void setFps(int fpsWish) +{ + static unsigned int fps = 0, fps_count = 0; // "static" permet de garder les valeurs en mémoire entre les différents appels + + do + { + fps = RTC_getTicks(); // on enregistre les ticks + Sleep(1); // permet d'économiser de la batterie + } + while(fps < fps_count + fpsWish); // tant que ceux-ci ne se sont pas suffisamment écoulés + + fps_count = RTC_getTicks(); // on met à jour les dernières valeurs +} + +int getDelay( int ms) +{ + static int time=0; + + if(RTC_getTicks() - time > (ms / 7.8125)) // si il s'est écoulé une seconde complète + { + time = RTC_getTicks(); // et on se rappelle du nombre de ticks de la dernière seconde écoulée + return 1; + } + +return 0; + +} + +int getFps() +{ + // variables utilisées (en static, pour pouvoir garder en mémoire les valeurs) + static int disp_fps=0, fps=1, time=0; + + if(RTC_getTicks() - time > 128) // si il s'est écoulé une seconde complète + { + disp_fps = fps; // alors on récupère le nombre de FPS + fps = 0; // on remet à 0 le compteur + time = RTC_getTicks(); // et on se rappelle du nombre de ticks de la dernière seconde écoulée + } + + fps++; // on monte la valeur des FPS + + return disp_fps; +} + +int rand_int(int max) +{ + return rand() % max; +} + +int rand_int_ab(int min, int max) +{ + return rand() % (max - min) + min; +} + +static int SysCallCode[] = {0xD201422B,0x60F20000,0x80010070}; +static int (*SysCall)( int R4, int R5, int R6, int R7, int FNo ) = (void*)&SysCallCode; + +int RTC_getTicks(void) +{ + return (*SysCall)(0, 0, 0, 0, 0x3B); // on déclare la fonction voulue selon son numéro (ici 0x3B) +} + + +float ABS( float v) +{ + if(v < 0) return -v; + return v; +} + +double degretorad(float v) +{ + return v * 3.1415 / 180; +} + +double radtodegre(float v) +{ + return v * 180 / 3.1415; +} diff --git a/otherlib/FonctionC.h b/otherlib/FonctionC.h new file mode 100644 index 0000000..ae2473f --- /dev/null +++ b/otherlib/FonctionC.h @@ -0,0 +1,11 @@ +#ifndef FONCTIONC +#define FONCTIONC + +int PrintV(int x, int y, int v); +int getFps(); +void setFps(int fpsWish); +int getDelay( int ms); + +int RTC_getTicks(void); + +#endif // FONCTIONC diff --git a/otherlib/MonochromeLib.c b/otherlib/MonochromeLib.c new file mode 100644 index 0000000..4922f51 --- /dev/null +++ b/otherlib/MonochromeLib.c @@ -0,0 +1,1559 @@ +/*************************************************************/ +/** MonochromeLib - monochrome graphic library for fx-9860G **/ +/** MonochromeLib is free software **/ +/** **/ +/** @author Pierre "PierrotLL" Le Gall **/ +/** @contact legallpierre89@gmail.com **/ +/** **/ +/** @file MonochromeLib.c **/ +/** Code file of MonochromeLib **/ +/** **/ +/** @date 11-22-2011 **/ +/*************************************************************/ + +#include "MonochromeLib.h" +#include +#include "fxlib.h" +#include "mathf.h" + + +/******************************/ +/** Dependencies management **/ +/******************************/ + +#ifdef ML_ALL + #define ML_CLEAR_VRAM + #define ML_CLEAR_SCREEN + #define ML_DISPLAY_VRAM + #define ML_SET_CONTRAST + #define ML_GET_CONTRAST + #define ML_PIXEL + #define ML_POINT + #define ML_PIXEL_TEST + #define ML_LINE + #define ML_HORIZONTAL_LINE + #define ML_VERTICAL_LINE + #define ML_RECTANGLE + #define ML_POLYGON + #define ML_FILLED_POLYGON + #define ML_CIRCLE + #define ML_FILLED_CIRCLE + #define ML_ELLIPSE + #define ML_ELLIPSE_IN_RECT + #define ML_FILLED_ELLIPSE + #define ML_FILLED_ELLIPSE_IN_RECT + #define ML_HORIZONTAL_SCROLL + #define ML_VERTICAL_SCROLL + #define ML_BMP_OR + #define ML_BMP_AND + #define ML_BMP_XOR + #define ML_BMP_OR_CL + #define ML_BMP_AND_CL + #define ML_BMP_XOR_CL + #define ML_BMP_8_OR + #define ML_BMP_8_AND + #define ML_BMP_8_XOR + #define ML_BMP_8_OR_CL + #define ML_BMP_8_AND_CL + #define ML_BMP_8_XOR_CL + #define ML_BMP_16_OR + #define ML_BMP_16_AND + #define ML_BMP_16_XOR + #define ML_BMP_16_OR_CL + #define ML_BMP_16_AND_CL + #define ML_BMP_16_XOR_CL + #define ML_BMP_OR_ZOOM + #define ML_BMP_AND_ZOOM + #define ML_BMP_XOR_ZOOM + #define ML_BMP_OR_ROTATE + #define ML_BMP_AND_ROTATE + #define ML_BMP_XOR_ROTATE +#endif + +#ifdef ML_POLYGON + #define ML_LINE +#endif + +#ifdef ML_LINE + #define ML_PIXEL +#endif + +#ifdef ML_POINT + #define ML_PIXEL + #define ML_RECTANGLE +#endif + +#ifdef ML_RECTANGLE + #define ML_HORIZONTAL_LINE +#endif + +#ifdef ML_FILLED_POLYGON + #define ML_HORIZONTAL_LINE +#endif + +#ifdef ML_CIRCLE + #define ML_PIXEL +#endif + +#ifdef ML_FILLED_CIRCLE + #define ML_HORIZONTAL_LINE +#endif + +#ifdef ML_ELLIPSE_IN_RECT + #define ML_ELLIPSE +#endif + +#ifdef ML_ELLIPSE + #define ML_PIXEL +#endif + +#ifdef ML_FILLED_ELLIPSE_IN_RECT + #define ML_FILLED_ELLIPSE +#endif + +#ifdef ML_FILLED_ELLIPSE + #define ML_HORIZONTAL_LINE +#endif + + +/***************/ +/** Functions **/ +/***************/ + +#define sgn(x) (x<0?-1:1) +#define rnd(x) ((int)(x+0.5)) + +//Thanks to Simon Lothar for this function + +static int SysCallCode[] = {0xD201422B,0x60F20000,0x80010070}; +static int (*SysCall)( int R4, int R5, int R6, int R7, int FNo ) = (void*)&SysCallCode; + +char* ML_vram_adress() +{ + return (char*)((*SysCall)(0, 0, 0, 0, 309)); +} + + +#ifdef ML_CLEAR_VRAM +void ML_clear_vram() +{ + int i, end, *pointer_long, vram; + char *pointer_byte; + vram = (int)ML_vram_adress(); + end = 4-vram&3; + pointer_byte = (char*)vram; + for(i=0 ; i>3)] |= 128>>(x&7); + break; + case ML_WHITE: + vram[(y<<4)+(x>>3)] &= ~(128>>(x&7)); + break; + case ML_XOR: + vram[(y<<4)+(x>>3)] ^= 128>>(x&7); + break; + case ML_CHECKER: + if(y&1^x&1) vram[(y<<4)+(x>>3)] &= ~(128>>(x&7)); + else vram[(y<<4)+(x>>3)] |= 128>>(x&7); + break; + } +} +#endif + +#ifdef ML_POINT +void ML_point(int x, int y, int width, ML_Color color) +{ + if(width < 1) return; + if(width == 1) ML_pixel(x, y, color); + else + { + int padding, pair; + padding = width>>1; + pair = !(width&1); + ML_rectangle(x-padding+pair, y-padding+pair, x+padding, y+padding, 0, 0, color); + } +} +#endif + +#ifdef ML_PIXEL_TEST +ML_Color ML_pixel_test(int x, int y) +{ + char *vram, byte; + if(x&~127 || y&~63) return ML_TRANSPARENT; + vram = ML_vram_adress(); + byte = 1<<(7-(x&7)); + return (vram[(y<<4)+(x>>3)] & byte ? ML_BLACK : ML_WHITE); + +} +#endif + +#ifdef ML_LINE +void ML_line(int x1, int y1, int x2, int y2, ML_Color color) +{ + int i, x, y, dx, dy, sx, sy, cumul; + x = x1; + y = y1; + dx = x2 - x1; + dy = y2 - y1; + sx = sgn(dx); + sy = sgn(dy); + dx = abs(dx); + dy = abs(dy); + ML_pixel(x, y, color); + if(dx > dy) + { + cumul = dx / 2; + for(i=1 ; i dx) + { + cumul -= dx; + y += sy; + } + ML_pixel(x, y, color); + } + } + else + { + cumul = dy / 2; + for(i=1 ; i dy) + { + cumul -= dy; + x += sx; + } + ML_pixel(x, y, color); + } + } +} +#endif + +#ifdef ML_HORIZONTAL_LINE +void ML_horizontal_line(int y, int x1, int x2, ML_Color color) +{ + int i; + char checker; + char* vram = ML_vram_adress(); + if(y&~63 || (x1<0 && x2<0) || (x1>127 && x2>127)) return; + if(x1 > x2) + { + i = x1; + x1 = x2; + x2 = i; + } + if(x1 < 0) x1 = 0; + if(x2 > 127) x2 = 127; + switch(color) + { + case ML_BLACK: + if(x1>>3 != x2>>3) + { + vram[(y<<4)+(x1>>3)] |= 255 >> (x1&7); + vram[(y<<4)+(x2>>3)] |= 255 << 7-(x2&7); + for(i=(x1>>3)+1 ; i>3 ; i++) + vram[(y<<4) + i] = 255; + } + else vram[(y<<4)+(x1>>3)] |= (255>>(x1%8 + 7-x2%8))<<(7-(x2&7)); + break; + case ML_WHITE: + if(x1>>3 != x2>>3) + { + vram[(y<<4)+(x1>>3)] &= 255 << 8-(x1&7); + vram[(y<<4)+(x2>>3)] &= 255 >> 1+(x2&7); + for(i=(x1>>3)+1 ; i>3 ; i++) + vram[(y<<4) + i] = 0; + } + else vram[(y<<4)+(x1>>3)] &= (255<<8-(x1&7)) | (255>>1+(x2&7)); + break; + case ML_XOR: + if(x1>>3 != x2>>3) + { + vram[(y<<4)+(x1>>3)] ^= 255 >> (x1&7); + vram[(y<<4)+(x2>>3)] ^= 255 << 7-(x2&7); + for(i=(x1>>3)+1 ; i<(x2>>3) ; i++) + vram[(y<<4) + i] ^= 255; + } + else vram[(y<<4)+(x1>>3)] ^= (255>>((x1&7) + 7-(x2&7)))<<(7-(x2&7)); + break; + case ML_CHECKER: + checker = (y&1 ? 85 : 170); + if(x1>>3 != x2>>3) + { + vram[(y<<4)+(x1>>3)] &= 255 << 8-(x1&7); + vram[(y<<4)+(x2>>3)] &= 255 >> 1+(x2&7); + vram[(y<<4)+(x1>>3)] |= checker & 255>>(x1&7); + vram[(y<<4)+(x2>>3)] |= checker & 255<<7-(x2&7); + for(i=(x1>>3)+1 ; i>3 ; i++) + vram[(y<<4) + i] = checker; + } + else + { + vram[(y<<4)+(x1>>3)] &= (255<<8-(x1&7)) | (255>>1+(x2&7)); + vram[(y<<4)+(x1>>3)] |= checker & (255>>(x1%8 + 7-x2%8))<<(7-(x2&7)); + } + break; + } +} + +#endif + +#ifdef ML_VERTICAL_LINE +void ML_vertical_line(int x, int y1, int y2, ML_Color color) +{ + int i, j; + char checker, byte, *vram = ML_vram_adress(); + if(x&~127 || (y1<0 && y2<0) || (y1>63 && y2>63)) return; + if(y1 > y2) + { + int tmp = y1; + y1 = y2; + y2 = tmp; + } + if(y1 < 0) y1 = 0; + if(y2 > 63) y2 = 63; + + i = (y1<<4)+(x>>3); + j = (y2<<4)+(x>>3); + switch(color) + { + case ML_BLACK: + byte = 128>>(x&7); + for( ; i<=j ; i+=16) + vram[i] |= byte; + break; + case ML_WHITE: + byte = ~(128>>(x&7)); + for( ; i<=j ; i+=16) + vram[i] &= byte; + break; + case ML_XOR: + byte = 128>>(x&7); + for( ; i<=j ; i+=16) + vram[i] ^= byte; + break; + case ML_CHECKER: + byte = 128>>(x&7); + checker = y1&1^x&1; + for( ; i<=j ; i+=16) + { + if(checker) vram[i] &= ~byte; + else vram[i] |= byte; + checker = !checker; + } + break; + } +} +#endif + +#ifdef ML_RECTANGLE +void ML_rectangle(int x1, int y1, int x2, int y2, int border_width, ML_Color border_color, ML_Color fill_color) +{ + int i; + if(x1 > x2) + { + i = x1; + x1 = x2; + x2 = i; + } + if(y1 > y2) + { + i = y1; + y1 = y2; + y2 = i; + } + if(border_width > (x2-x1)/2+1) border_width = (x2-x1)/2+1; + if(border_width > (y2-y1)/2+1) border_width = (y2-y1)/2+1; + if(border_color != ML_TRANSPARENT && border_width > 0) + { + for(i=0 ; i t[i]) + { + j++; + tmp = t[j]; + t[j] = t[i]; + t[i] = tmp; + } + } + t[r] = t[j+1]; + t[j+1] = x; + return j + 1; +} + +static void ML_filled_polygon_quicksord(int* t, int p, int r) +{ + int q; + if(p < r) + { + q = ML_filled_polygon_quicksord_partition(t, p, r); + ML_filled_polygon_quicksord(t, p, q-1); + ML_filled_polygon_quicksord(t, q+1, r); + } +} + + +void ML_filled_polygon(const int *x, const int *y, int nb_vertices, ML_Color color) +{ + int i, j, dx, dy, ymin, ymax; + int *cut_in_line, nb_cut; + if(nb_vertices < 3) return; + cut_in_line = malloc(nb_vertices*sizeof(int)); + if(!cut_in_line) return; + ymin = ymax = y[0]; + for(i=1 ; i ymax) ymax = y[i]; + } + for(i=ymin ; i<=ymax ; i++) + { + nb_cut = 0; + for(j=0 ; j=i) || (y[j]>=i && y[(j+1)%nb_vertices]<=i)) + { + dy = abs(y[j]-y[(j+1)%nb_vertices]); + if(dy) + { + dx = x[(j+1)%nb_vertices]-x[j]; + cut_in_line[nb_cut] = x[j] + rnd(abs(i-y[j]+sgn(i-y[j])/2)*dx/dy); + nb_cut++; + } + } + } + ML_filled_polygon_quicksord(cut_in_line, 0, nb_cut-1); + j = 0; + while(j plot_x) + { + if(d < 0) + d += 2*plot_x+3; + else + { + d += 2*(plot_x-plot_y)+5; + plot_y--; + } + plot_x++; + if(plot_y >= plot_x) + { + ML_pixel(x+plot_x, y+plot_y, color); + ML_pixel(x-plot_x, y+plot_y, color); + ML_pixel(x+plot_x, y-plot_y, color); + ML_pixel(x-plot_x, y-plot_y, color); + } + if(plot_y > plot_x) + { + ML_pixel(x+plot_y, y+plot_x, color); + ML_pixel(x-plot_y, y+plot_x, color); + ML_pixel(x+plot_y, y-plot_x, color); + ML_pixel(x-plot_y, y-plot_x, color); + } + } +} +#endif + +#ifdef ML_FILLED_CIRCLE +void ML_filled_circle(int x, int y, int radius, ML_Color color) +{ + int plot_x, plot_y, d; + + if(radius < 0) return; + plot_x = 0; + plot_y = radius; + d = 1 - radius; + + ML_horizontal_line(y, x-plot_y, x+plot_y, color); + while(plot_y > plot_x) + { + if(d < 0) + d += 2*plot_x+3; + else { + d += 2*(plot_x-plot_y)+5; + plot_y--; + ML_horizontal_line(y+plot_y+1, x-plot_x, x+plot_x, color); + ML_horizontal_line(y-plot_y-1, x-plot_x, x+plot_x, color); + } + plot_x++; + if(plot_y >= plot_x) + { + ML_horizontal_line(y+plot_x, x-plot_y, x+plot_y, color); + ML_horizontal_line(y-plot_x, x-plot_y, x+plot_y, color); + } + } +} +#endif + +#ifdef ML_ELLIPSE +void ML_ellipse(int x, int y, int radius1, int radius2, ML_Color color) +{ + int plot_x, plot_y; + float d1, d2; + if(radius1 < 1 || radius2 < 1) return; + plot_x = 0; + plot_y = radius2; + d1 = radius2*radius2 - radius1*radius1*radius2 + radius1*radius1/4; + ML_pixel(x, y+plot_y, color); + ML_pixel(x, y-plot_y, color); + while(radius1*radius1*(plot_y-.5) > radius2*radius2*(plot_x+1)) + { + if(d1 < 0) + { + d1 += radius2*radius2*(2*plot_x+3); + plot_x++; + } else { + d1 += radius2*radius2*(2*plot_x+3) + radius1*radius1*(-2*plot_y+2); + plot_x++; + plot_y--; + } + ML_pixel(x+plot_x, y+plot_y, color); + ML_pixel(x-plot_x, y+plot_y, color); + ML_pixel(x+plot_x, y-plot_y, color); + ML_pixel(x-plot_x, y-plot_y, color); + } + d2 = radius2*radius2*(plot_x+.5)*(plot_x+.5) + radius1*radius1*(plot_y-1)*(plot_y-1) - radius1*radius1*radius2*radius2; + while(plot_y > 0) + { + if(d2 < 0) + { + d2 += radius2*radius2*(2*plot_x+2) + radius1*radius1*(-2*plot_y+3); + plot_y--; + plot_x++; + } else { + d2 += radius1*radius1*(-2*plot_y+3); + plot_y--; + } + ML_pixel(x+plot_x, y+plot_y, color); + ML_pixel(x-plot_x, y+plot_y, color); + if(plot_y > 0) + { + ML_pixel(x+plot_x, y-plot_y, color); + ML_pixel(x-plot_x, y-plot_y, color); + } + } +} +#endif + +#ifdef ML_ELLIPSE_IN_RECT +void ML_ellipse_in_rect(int x1, int y1, int x2, int y2, ML_Color color) +{ + int radius1, radius2; + if(x1 > x2) + { + int tmp = x1; + x1 = x2; + x2 = tmp; + } + if(y1 > y2) + { + int tmp = y1; + y1 = y2; + y2 = tmp; + } + radius1 = (x2-x1)/2; + radius2 = (y2-y1)/2; + ML_ellipse(x1+radius1, y1+radius2, radius1, radius2, color); +} +#endif + +#ifdef ML_FILLED_ELLIPSE +void ML_filled_ellipse(int x, int y, int radius1, int radius2, ML_Color color) +{ + int plot_x, plot_y; + float d1, d2; + if(radius1 < 1 || radius2 < 1) return; + plot_x = 0; + plot_y = radius2; + d1 = radius2*radius2 - radius1*radius1*radius2 + radius1*radius1/4; + while(radius1*radius1*(plot_y-.5) > radius2*radius2*(plot_x+1)) + { + if(d1 < 0) + { + d1 += radius2*radius2*(2*plot_x+3); + plot_x++; + } else { + d1 += radius2*radius2*(2*plot_x+3) + radius1*radius1*(-2*plot_y+2); + ML_horizontal_line(y+plot_y, x-plot_x, x+plot_x, color); + ML_horizontal_line(y-plot_y, x-plot_x, x+plot_x, color); + plot_x++; + plot_y--; + } + } + ML_horizontal_line(y+plot_y, x-plot_x, x+plot_x, color); + ML_horizontal_line(y-plot_y, x-plot_x, x+plot_x, color); + d2 = radius2*radius2*(plot_x+.5)*(plot_x+.5) + radius1*radius1*(plot_y-1)*(plot_y-1) - radius1*radius1*radius2*radius2; + while(plot_y > 0) + { + if(d2 < 0) + { + d2 += radius2*radius2*(2*plot_x+2) + radius1*radius1*(-2*plot_y+3); + plot_y--; + plot_x++; + } else { + d2 += radius1*radius1*(-2*plot_y+3); + plot_y--; + } + ML_horizontal_line(y+plot_y, x-plot_x, x+plot_x, color); + if(plot_y > 0) + ML_horizontal_line(y-plot_y, x-plot_x, x+plot_x, color); + } +} +#endif + +#ifdef ML_FILLED_ELLIPSE_IN_RECT +void ML_filled_ellipse_in_rect(int x1, int y1, int x2, int y2, ML_Color color) +{ + int radius1, radius2; + if(x1 > x2) + { + int tmp = x1; + x1 = x2; + x2 = tmp; + } + if(y1 > y2) + { + int tmp = y1; + y1 = y2; + y2 = tmp; + } + radius1 = (x2-x1)/2; + radius2 = (y2-y1)/2; + ML_filled_ellipse(x1+radius1, y1+radius2, radius1, radius2, color); +} +#endif + +#ifdef ML_HORIZONTAL_SCROLL +void ML_horizontal_scroll(int scroll) +{ + int i, j; + char line[16], shift, *vram; + unsigned char next; + unsigned short word; + vram = ML_vram_adress(); + scroll %= 128; + shift = 8-(scroll&7); + for(i=0 ; i<64 ; i++) + { + for(j=0 ; j<16 ; j++) line[j] = vram[(i<<4)+((j-(scroll>>3)+15)&15)]; + next = line[15]; + vram[(i<<4)+15] = 0; + for(j=15 ; j>0 ; j--) + { + word = next << shift; + next = line[j-1]; + vram[(i<<4)+j] |= *((char*)&word+1); + vram[(i<<4)+j-1] = *((char*)&word); + } + word = next << shift; + vram[(i<<4)] |= *((char*)&word+1); + vram[(i<<4)+15] |= *((char*)&word); + } +} +#endif + +#ifdef ML_VERTICAL_SCROLL +void ML_vertical_scroll(int scroll) +{ + int i, j; + char column[64], *vram = ML_vram_adress(); + scroll %= 64; + for(i=0 ; i<16 ; i++) + { + for(j=0 ; j<64 ; j++) column[j] = vram[(j<<4)+i]; + for(j=0 ; j<64 ; j++) vram[(j<<4)+i] = column[(j-scroll+64)&63]; + } +} +#endif + +#ifdef ML_BMP_OR +void ML_bmp_or(const unsigned char *bmp, int x, int y, int width, int height) +{ + unsigned short line; + char shift, *screen, *p=(char*)&line; + int i, j, begin=0, end=height, real_width=(width-1>>3<<3)+8; + if(!bmp || x<0 || x>128-width || y<1-height || y>63 || width<1 || height<1) return; + if(y < 0) begin = -y; + if(y+height > 64) end = 64-y; + shift = 8-(x&7); + screen = ML_vram_adress()+(y+begin<<4)+(x>>3); + for(i=begin ; i>3 ; j++) + { + line = bmp[i*(real_width>>3)+j]<>3)+j] & -1<<(real_width-width))<>3<<3)+8; + if(!bmp || x<0 || x>128-width || y<1-height || y>63 || width<1 || height<1) return; + if(y < 0) begin = -y; + if(y+height > 64) end = 64-y; + shift = 8-(x&7); + screen = ML_vram_adress()+(y+begin<<4)+(x>>3); + for(i=begin ; i>3 ; j++) + { + line = ~((unsigned char)~bmp[i*(real_width>>3)+j]<>3)+j] | (unsigned char)-1>>8-(width&7))<>3<<3)+8; + if(!bmp || x<0 || x>128-width || y<1-height || y>63 || width<1 || height<1) return; + if(y < 0) begin = -y; + if(y+height > 64) end = 64-y; + shift = 8-(x&7); + screen = ML_vram_adress()+(y+begin<<4)+(x>>3); + for(i=begin ; i>3 ; j++) + { + line = bmp[i*(real_width>>3)+j]<>3)+j] & -1<<(real_width-width))<127 || y<1-height || y>63 || height<1 || width<1) return; + p = (char*)&line; + real_width = (width-1>>3<<3)+8; + if(y < 0) begin_y = -y; + else begin_y = 0; + if(y+height > 64) end_y = 64-y; + else end_y = height; + shift = 8-(x&7); + if(x<0) + { + begin_x = -x>>3; + if(shift != 8) bool1 = 0; + } else begin_x = 0; + if(x+real_width > 128) end_x = 15-(x>>3), bool2 = 0; + else end_x = real_width-1>>3; + bool3 = (end_x == real_width-1>>3); + screen = ML_vram_adress()+(y+begin_y<<4)+(x>>3); + + for(i=begin_y ; i>3)+begin_x] << shift; + if(bool1) screen[begin_x] |= *p; + if(shift!=8) screen[begin_x+1] |= *(p+1); + for(j=begin_x+1 ; j>3)+j] << shift; + screen[j] |= *p; + if(shift!=8) screen[j+1] |= *(p+1); + } + } + line = bmp[i*(real_width>>3)+end_x]; + if(bool3) line &= -1<127 || y<1-height || y>63 || height<1 || width<1) return; + p = (char*)&line; + real_width = (width-1>>3<<3)+8; + if(y < 0) begin_y = -y; + else begin_y = 0; + if(y+height > 64) end_y = 64-y; + else end_y = height; + shift = 8-(x&7); + if(x<0) + { + begin_x = -x>>3; + if(shift != 8) bool1 = 0; + } else begin_x = 0; + if(x+real_width > 128) end_x = 15-(x>>3), bool2 = 0; + else end_x = real_width-1>>3; + bool3 = (end_x == real_width-1>>3); + screen = ML_vram_adress()+(y+begin_y<<4)+(x>>3); + + for(i=begin_y ; i>3)+begin_x]<>3)+j]<>3)+end_x]; + if(bool3) line &= -1<127 || y<1-height || y>63 || height<1 || width<1) return; + p = (char*)&line; + real_width = (width-1>>3<<3)+8; + if(y < 0) begin_y = -y; + else begin_y = 0; + if(y+height > 64) end_y = 64-y; + else end_y = height; + shift = 8-(x&7); + if(x<0) + { + begin_x = -x>>3; + if(shift != 8) bool1 = 0; + } else begin_x = 0; + if(x+real_width > 128) end_x = 15-(x>>3), bool2 = 0; + else end_x = real_width-1>>3; + bool3 = (end_x == real_width-1>>3); + screen = ML_vram_adress()+(y+begin_y<<4)+(x>>3); + + for(i=begin_y ; i>3)+begin_x] << shift; + if(bool1) screen[begin_x] ^= *p; + if(shift!=8) screen[begin_x+1] ^= *(p+1); + for(j=begin_x+1 ; j>3)+j] << shift; + screen[j] ^= *p; + if(shift!=8) screen[j+1] ^= *(p+1); + } + } + line = bmp[i*(real_width>>3)+end_x]; + if(bool3) line &= -1<120 || y<-7 || y>63) return; + if(y < 0) begin = -y; + if(y > 56) end = 64-y; + shift = 8-(x&7); + screen = ML_vram_adress()+(y+begin<<4)+(x>>3); + for(i=begin ; i120 || y<-7 || y>63) return; + if(y < 0) begin = -y; + if(y > 56) end = 64-y; + shift = 8-(x&7); + screen = ML_vram_adress()+(y+begin<<4)+(x>>3); + for(i=begin ; i120 || y<-7 || y>63) return; + if(y < 0) begin = -y; + if(y > 56) end = 64-y; + shift = 8-(x&7); + screen = ML_vram_adress()+(y+begin<<4)+(x>>3); + for(i=begin ; i127 || y<-7 || y>63) return; + if(y < 0) begin = -y; + if(y > 56) end = 64-y; + shift = 8-(x&7); + if(x < 0) bool1 = 0; + if(x>120 || shift==8) bool2 = 0; + screen = ML_vram_adress()+(y+begin<<4)+(x>>3); + for(i=begin ; i127 || y<-7 || y>63) return; + if(y < 0) begin = -y; + if(y > 56) end = 64-y; + shift = 8-(x&7); + if(x < 0) bool1 = 0; + if(x>120 || shift==8) bool2 = 0; + screen = ML_vram_adress()+(y+begin<<4)+(x>>3); + for(i=begin ; i127 || y<-7 || y>63) return; + if(y < 0) begin = -y; + if(y > 56) end = 64-y; + shift = 8-(x&7); + if(x < 0) bool1 = 0; + if(x>120 || shift==8) bool2 = 0; + screen = ML_vram_adress()+(y+begin<<4)+(x>>3); + for(i=begin ; i112 || y<-15 || y>63) return; + if(y < 0) begin = -y; + if(y > 48) end = 64-y; + shift = 8-(x&7); + screen = ML_vram_adress()+(y+begin<<4)+(x>>3); + for(i=begin ; i112 || y<-15 || y>63) return; + if(y < 0) begin = -y; + if(y > 48) end = 64-y; + shift = 8-(x&7); + screen = ML_vram_adress()+(y+begin<<4)+(x>>3); + for(i=begin ; i112 || y<-15 || y>63) return; + if(y < 0) begin = -y; + if(y > 48) end = 64-y; + shift = 8-(x&7); + screen = ML_vram_adress()+(y+begin<<4)+(x>>3); + for(i=begin ; i127 || y<-15 || y>63) return; + if(y < 0) begin = -y; + if(y > 48) end = 64-y; + shift = 8-(x&7); + if(x < 0) bool1 = 0; + if(x<-8 || x>119) bool2 = 0; + if(x>111 || shift==8) bool3 = 0; + screen = ML_vram_adress()+(y+begin<<4)+(x>>3); + for(i=begin ; i127 || y<-15 || y>63) return; + if(y < 0) begin = -y; + if(y > 48) end = 64-y; + shift = 8-(x&7); + if(x < 0) bool1 = 0; + if(x<-8 || x>119) bool2 = 0; + if(x>111 || shift==8) bool3 = 0; + screen = ML_vram_adress()+(y+begin<<4)+(x>>3); + for(i=begin ; i127 || y<-15 || y>63) return; + if(y < 0) begin = -y; + if(y > 48) end = 64-y; + shift = 8-(x&7); + if(x < 0) bool1 = 0; + if(x<-8 || x>119) bool2 = 0; + if(x>111 || shift==8) bool3 = 0; + screen = ML_vram_adress()+(y+begin<<4)+(x>>3); + for(i=begin ; i> 14 ; + height_z = height * zoom_h14 >> 14; + nb_width = width + 7 >> 3; + + if (x < 0) begin_x = -x; + else begin_x = 0; + if (x+width_z > 128) end_x = 128-x; + else end_x = width_z; + if (y < 0) begin_y = -y; + else begin_y = 0; + if (y+height_z > 64) end_y = 64-y; + else end_y = height_z; + + for (iz=begin_x; iz> 3; + bit = 0x80 >> (i & 7); + x_screen = x+iz; + + for (jz=begin_y; jz>3)] |= 128>>(x_screen&7); + } + } +} +#endif + +#ifdef ML_BMP_AND_ZOOM +void ML_bmp_and_zoom(const unsigned char *bmp, int x, int y, int width, int height, float zoom_w, float zoom_h) +{ + int i, j, iz, jz, width_z, height_z, nb_width, i3, bit, x_screen, pixel; + int zoom_w14, zoom_h14; + int begin_x, end_x, begin_y, end_y; + char* vram = ML_vram_adress(); + + if (!bmp) return; + if (zoom_h < 0) zoom_h = 0; + if (zoom_w < 0) zoom_w = 0; + zoom_w14 = zoom_w * 16384; + zoom_h14 = zoom_h * 16384; + width_z = width * zoom_w14 >> 14 ; + height_z = height * zoom_h14 >> 14; + nb_width = width + 7 >> 3; + + if (x < 0) begin_x = -x; + else begin_x = 0; + if (x+width_z > 128) end_x = 128-x; + else end_x = width_z; + if (y < 0) begin_y = -y; + else begin_y = 0; + if (y+height_z > 64) end_y = 64-y; + else end_y = height_z; + + for (iz=begin_x; iz> 3; + bit = 0x80 >> (i & 7); + x_screen = x+iz; + + for (jz=begin_y; jz>3)] &= ~(128>>(x_screen&7)); + } + } +} +#endif + +#ifdef ML_BMP_XOR_ZOOM +void ML_bmp_xor_zoom(const unsigned char *bmp, int x, int y, int width, int height, float zoom_w, float zoom_h) +{ + int i, j, iz, jz, width_z, height_z, nb_width, i3, bit, x_screen, pixel; + int zoom_w14, zoom_h14; + int begin_x, end_x, begin_y, end_y; + char* vram = ML_vram_adress(); + + if (!bmp) return; + if (zoom_h < 0) zoom_h = 0; + if (zoom_w < 0) zoom_w = 0; + zoom_w14 = zoom_w * 16384; + zoom_h14 = zoom_h * 16384; + width_z = width * zoom_w14 >> 14 ; + height_z = height * zoom_h14 >> 14; + nb_width = width + 7 >> 3; + + if (x < 0) begin_x = -x; + else begin_x = 0; + if (x+width_z > 128) end_x = 128-x; + else end_x = width_z; + if (y < 0) begin_y = -y; + else begin_y = 0; + if (y+height_z > 64) end_y = 64-y; + else end_y = height_z; + + for (iz=begin_x; iz> 3; + bit = 0x80 >> (i & 7); + x_screen = x+iz; + + for (jz=begin_y; jz>3)] ^= 128>>(x_screen&7); + } + } +} +#endif + +#ifdef ML_BMP_OR_ROTATE +void ML_bmp_or_rotate(const unsigned char *bmp, int x, int y, int width, int height, int angle) +{ + int i, j, i3, dx, dy, ox, oy, xr, yr, nb_width, pixel, bit; + int cosinus, sinus; + char* vram = ML_vram_adress(); + + if (!bmp) return; + ox = x + width / 2; + oy = y + height / 2; + angle %= 360; + if (angle < 0) angle += 360; + if (angle == 0) {cosinus = 16384; sinus = 0;} + else if (angle == 90) {cosinus = 0; sinus = -16384;} + else if (angle == 180) {cosinus = -16384; sinus = 0;} + else if (angle == 270) {cosinus = 0; sinus = 16384;} + else + { + cosinus = cosf(-3.14 * angle / 180.0) * 16384; + sinus = sinf(-3.14 * angle / 180.0) * 16384; + } + nb_width = width + 7 >> 3; + + for (i=0; i> (i & 7); + i3 = i >> 3; + dx = x + i - ox; + for (j=0; j> 14); + yr = oy + (dx * sinus + dy * cosinus >> 14); + if (!(xr < 0 || xr > 127 || yr < 0 || yr > 63)) + { + pixel = bmp[i3 + nb_width * j] & bit; + if (pixel != 0) vram[(yr<<4)+(xr>>3)] |= 128>>(xr&7); + } + } + } +} +#endif + +#ifdef ML_BMP_AND_ROTATE +void ML_bmp_and_rotate(const unsigned char *bmp, int x, int y, int width, int height, int angle) +{ + int i, j, i3, dx, dy, ox, oy, xr, yr, nb_width, pixel, bit; + int cosinus, sinus; + char* vram = ML_vram_adress(); + + if (!bmp) return; + ox = x + width / 2; + oy = y + height / 2; + angle %= 360; + if (angle < 0) angle += 360; + if (angle == 0) {cosinus = 16384; sinus = 0;} + else if (angle == 90) {cosinus = 0; sinus = -16384;} + else if (angle == 180) {cosinus = -16384; sinus = 0;} + else if (angle == 270) {cosinus = 0; sinus = 16384;} + else + { + cosinus = cosf(-3.14 * angle / 180.0) * 16384; + sinus = sinf(-3.14 * angle / 180.0) * 16384; + } + nb_width = width + 7 >> 3; + + for (i=0; i> (i & 7); + i3 = i >> 3; + dx = x + i - ox; + for (j=0; j> 14); + yr = oy + (dx * sinus + dy * cosinus >> 14); + if (!(xr < 0 || xr > 127 || yr < 0 || yr > 63)) + { + pixel = bmp[i3 + nb_width * j] & bit; + if (pixel == 0) vram[(yr<<4)+(xr>>3)] &= ~(128>>(xr&7)); + } + } + } +} +#endif + +#ifdef ML_BMP_XOR_ROTATE +void ML_bmp_xor_rotate(const unsigned char *bmp, int x, int y, int width, int height, int angle) +{ + int i, j, i3, dx, dy, ox, oy, xr, yr, nb_width, pixel, bit; + int cosinus, sinus; + char* vram = ML_vram_adress(); + + if (!bmp) return; + ox = x + width / 2; + oy = y + height / 2; + angle %= 360; + if (angle < 0) angle += 360; + if (angle == 0) {cosinus = 16384; sinus = 0;} + else if (angle == 90) {cosinus = 0; sinus = -16384;} + else if (angle == 180) {cosinus = -16384; sinus = 0;} + else if (angle == 270) {cosinus = 0; sinus = 16384;} + else + { + cosinus = cosf(-3.14 * angle / 180.0) * 16384; + sinus = sinf(-3.14 * angle / 180.0) * 16384; + } + nb_width = width + 7 >> 3; + + for (i=0; i> (i & 7); + i3 = i >> 3; + dx = x + i - ox; + for (j=0; j> 14); + yr = oy + (dx * sinus + dy * cosinus >> 14); + if (!(xr < 0 || xr > 127 || yr < 0 || yr > 63)) + { + pixel = bmp[i3 + nb_width * j] & bit; + if (pixel != 0) vram[(yr<<4)+(xr>>3)] ^= 128>>(xr&7); + } + } + } +} +#endif diff --git a/otherlib/MonochromeLib.h b/otherlib/MonochromeLib.h new file mode 100644 index 0000000..a935ad2 --- /dev/null +++ b/otherlib/MonochromeLib.h @@ -0,0 +1,167 @@ +/*************************************************************/ +/** MonochromeLib - monochrome graphic library for fx-9860G **/ +/** MonochromeLib is free software **/ +/** **/ +/** @author Pierre "PierrotLL" Le Gall **/ +/** @contact legallpierre89@gmail.com **/ +/** **/ +/** @file MonochromeLib.h **/ +/** Include header for MonochromeLib **/ +/** **/ +/** @date 11-22-2011 **/ +/*************************************************************/ + +#ifndef MONOCHROMELIB +#define MONOCHROMELIB + +/****************************************************/ +/** uncomment #define of functions you want to use **/ +/****************************************************/ + + #define ML_ALL //Auto define all functions + +// #define ML_CLEAR_VRAM +// #define ML_CLEAR_SCREEN +// #define ML_DISPLAY_VRAM + +// #define ML_SET_CONTRAST +// #define ML_GET_CONTRAST + +// #define ML_PIXEL +// #define ML_POINT +// #define ML_PIXEL_TEST + +// #define ML_LINE +// #define ML_HORIZONTAL_LINE +// #define ML_VERTICAL_LINE + +// #define ML_RECTANGLE + +// #define ML_POLYGON +// #define ML_FILLED_POLYGON + +// #define ML_CIRCLE +// #define ML_FILLED_CIRCLE + +// #define ML_ELLIPSE +// #define ML_ELLIPSE_IN_RECT +// #define ML_FILLED_ELLIPSE +// #define ML_FILLED_ELLIPSE_IN_RECT + +// #define ML_HORIZONTAL_SCROLL +// #define ML_VERTICAL_SCROLL + +// #define ML_BMP_OR +// #define ML_BMP_AND +// #define ML_BMP_XOR +// #define ML_BMP_OR_CL +// #define ML_BMP_AND_CL +// #define ML_BMP_XOR_CL + +// #define ML_BMP_8_OR +// #define ML_BMP_8_AND +// #define ML_BMP_8_XOR +// #define ML_BMP_8_OR_CL +// #define ML_BMP_8_AND_CL +// #define ML_BMP_8_XOR_CL + +// #define ML_BMP_16_OR +// #define ML_BMP_16_AND +// #define ML_BMP_16_XOR +// #define ML_BMP_16_OR_CL +// #define ML_BMP_16_AND_CL +// #define ML_BMP_16_XOR_CL + +// #define ML_BMP_OR_ZOOM +// #define ML_BMP_AND_ZOOM +// #define ML_BMP_XOR_ZOOM + +// #define ML_BMP_OR_ROTATE +// #define ML_BMP_AND_ROTATE +// #define ML_BMP_XOR_ROTATE + + +/**************************/ +/** Functions prototypes **/ +/**************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#define ML_SCREEN_WIDTH 128 +#define ML_SCREEN_HEIGHT 64 + +#define ML_CONTRAST_MIN 130 +#define ML_CONTRAST_NORMAL 168 +#define ML_CONTRAST_MAX 190 +typedef enum {ML_TRANSPARENT=-1, ML_WHITE, ML_BLACK, ML_XOR, ML_CHECKER} ML_Color; + +char* ML_vram_adress(); + +void ML_clear_vram(); +void ML_clear_screen(); +void ML_display_vram(); + +void ML_set_contrast(unsigned char contrast); +unsigned char ML_get_contrast(); + +void ML_pixel(int x, int y, ML_Color color); +void ML_point(int x, int y, int width, ML_Color color); +ML_Color ML_pixel_test(int x, int y); + +void ML_line(int x1, int y1, int x2, int y2, ML_Color color); +void ML_horizontal_line(int y, int x1, int x2, ML_Color color); +void ML_vertical_line(int x, int y1, int y2, ML_Color color); + +void ML_rectangle(int x1, int y1, int x2, int y2, int border_width, ML_Color border_color, ML_Color fill_color); + +void ML_polygon(const int *x, const int *y, int nb_vertices, ML_Color color); +void ML_filled_polygon(const int *x, const int *y, int nb_vertices, ML_Color color); + +void ML_circle(int x, int y, int radius, ML_Color color); +void ML_filled_circle(int x, int y, int radius, ML_Color color); + +void ML_ellipse(int x, int y, int radius1, int radius2, ML_Color color); +void ML_ellipse_in_rect(int x1, int y1, int x2, int y2, ML_Color color); +void ML_filled_ellipse(int x, int y, int radius1, int radius2, ML_Color color); +void ML_filled_ellipse_in_rect(int x, int y, int radius1, int radius2, ML_Color color); + +void ML_horizontal_scroll(int scroll); +void ML_vertical_scroll(int scroll); + +void ML_bmp_or(const unsigned char *bmp, int x, int y, int width, int height); +void ML_bmp_and(const unsigned char *bmp, int x, int y, int width, int height); +void ML_bmp_xor(const unsigned char *bmp, int x, int y, int width, int height); +void ML_bmp_or_cl(const unsigned char *bmp, int x, int y, int width, int height); +void ML_bmp_and_cl(const unsigned char *bmp, int x, int y, int width, int height); +void ML_bmp_xor_cl(const unsigned char *bmp, int x, int y, int width, int height); + +void ML_bmp_8_or(const unsigned char *bmp, int x, int y); +void ML_bmp_8_and(const unsigned char *bmp, int x, int y); +void ML_bmp_8_xor(const unsigned char *bmp, int x, int y); +void ML_bmp_8_or_cl(const unsigned char *bmp, int x, int y); +void ML_bmp_8_and_cl(const unsigned char *bmp, int x, int y); +void ML_bmp_8_xor_cl(const unsigned char *bmp, int x, int y); + +void ML_bmp_16_or(const unsigned short *bmp, int x, int y); +void ML_bmp_16_and(const unsigned short *bmp, int x, int y); +void ML_bmp_16_xor(const unsigned short *bmp, int x, int y); +void ML_bmp_16_or_cl(const unsigned short *bmp, int x, int y); +void ML_bmp_16_and_cl(const unsigned short *bmp, int x, int y); +void ML_bmp_16_xor_cl(const unsigned short *bmp, int x, int y); + +void ML_bmp_or_zoom(const unsigned char *bmp, int x, int y, int width, int height, float zoom_w, float zoom_h); +void ML_bmp_and_zoom(const unsigned char *bmp, int x, int y, int width, int height, float zoom_w, float zoom_h); +void ML_bmp_xor_zoom(const unsigned char *bmp, int x, int y, int width, int height, float zoom_w, float zoom_h); + +void ML_bmp_or_rotate(const unsigned char *bmp, int x, int y, int width, int height, int angle); +void ML_bmp_and_rotate(const unsigned char *bmp, int x, int y, int width, int height, int angle); +void ML_bmp_xor_rotate(const unsigned char *bmp, int x, int y, int width, int height, int angle); + +#ifdef __cplusplus +} +#endif + + +#endif //MONOCHROMELIB diff --git a/otherlib/input.c b/otherlib/input.c new file mode 100644 index 0000000..01b8c07 --- /dev/null +++ b/otherlib/input.c @@ -0,0 +1,233 @@ +/****************************************************************************/ +/* */ +/* Input */ +/* */ +/* Par NineStars V2 */ +/****************************************************************************/ + +#include "input.h" + +static int SysCallCode[] = {0xD201422B,0x60F20000,0x80010070}; +static int (*SysCall)( int R4, int R5, int R6, int R7, int FNo ) = (void*)&SysCallCode; + +unsigned char last_key[54] = {0}; +unsigned char current_key[54] = {0}; + + +void input_update() +{ + int i; + for (i=0; i<54; i++) + { + last_key[i] = current_key[i]; + if (key_down(i+25)) + { + if (current_key[i] < 255) + { + current_key[i] ++; + } + } else { + current_key[i] = 0; + } + + } +} + +int input_any_key() +{ + int i; + for (i=0; i<54; i++) + { + if (current_key[i] > 0) + { + return 1; + } + } + return 0; +} + +int input_press(char key) +{ + key -= 25; + return current_key[key]; +} + +int input_trigger(char key) +{ + key -= 25; + return (current_key[key] == 1); +} + +int input_release(char key) +{ + key -= 25; + return (last_key[key] && !current_key[key]); +} + +int input_hold_short(char key) +{ + key -= 25; + return current_key[key] > 7; +} + +int input_hold_long(char key) +{ + key -= 25; + return current_key[key] > 14; +} + +int input_repeat(char key) +{ + key -= 25; + if (current_key[key] == 1) + { + return 1; + } + if (current_key[key] == 8) + { + current_key[key] = 6; + return 1; + } + return 0; +} + +int input_repeat_short(char key) +{ + key -= 25; + if (current_key[key] == 1) + { + return 1; + } + if (current_key[key] == 5) + { + current_key[key] = 3; + return 1; + } + return 0; +} + +int input_dir4() +{ + if (current_key[K_DOWN-25]) return 2; + if (current_key[K_LEFT-25]) return 4; + if (current_key[K_RIGHT-25]) return 6; + if (current_key[K_UP-25]) return 8; + return 0; +} + +int input_dir8() +{ + if (current_key[K_LEFT-25] && current_key[K_DOWN-25]) return 1; + if (current_key[K_DOWN-25] && current_key[K_RIGHT-25]) return 3; + if (current_key[K_LEFT-25] && current_key[K_UP-25]) return 7; + if (current_key[K_RIGHT-25] && current_key[K_UP-25]) return 9; + if (current_key[K_DOWN-25]) return 2; + if (current_key[K_LEFT-25]) return 4; + if (current_key[K_RIGHT-25]) return 6; + if (current_key[K_UP-25]) return 8; + return 0; +} + + +#define SCA 0xD201D002 +#define SCB 0x422B0009 +#define SCE 0x80010070 + +typedef int(*sc_i2cp2sip) (char*, char*, short int*, short int*); +typedef int(*sc_iv) (void); +typedef int(*sc_4i) (int, int, int); + +const unsigned int sc003b[] = {SCA, SCB, SCE, 0x3B}; +const unsigned int sc0015[] = {SCA, SCB, SCE, 0x15}; +const unsigned int sc0248[] = {SCA, SCB, SCE, 0x248}; + +#define RTC_GetTicks (*(sc_iv)sc003b) +#define PutKey (*(sc_4i)sc0248) +#define GlibGetOSVersionInfo (*(sc_i2cp2sip)sc0015) + +int OSVersionAsInt(void) +{ + unsigned char mainversion; + unsigned char minorversion; + unsigned short release; + unsigned short build; + GlibGetOSVersionInfo( &mainversion, &minorversion, &release, &build ); + return ( ( mainversion << 24 ) & 0xFF000000 ) | ( ( minorversion << 16 ) & 0x00FF0000 ) | ( release & 0x0000FFFF ); +} +#define isOS2 (OSVersionAsInt() >= 0x02020000) +#define OS2(x,y) ((OSVersionAsInt() >= 0x02020000)?y:x) + +void key_inject(int keycode) +{ + (*SysCall)(keycode, 0, 0, 0, 0x248); +} + +static void delay() +{ + unsigned char i; + for(i=0 ; i<5 ; i++); +} + +unsigned char CheckKeyRow(unsigned char code) +{ + unsigned char result=0; + short*PORTB_CTRL=(void*)0xA4000102; + short*PORTM_CTRL=(void*)0xA4000118; + char*PORTB=(void*)0xA4000122; + char*PORTM=(void*)0xA4000138; + char*PORTA=(void*)0xA4000120; + short smask; + char cmask; + unsigned char column, row; + + column = code>>4; + row = code &0x0F; + + smask = 0x0003 << (( row %8)*2); + cmask = ~( 1 << ( row %8) ); + if(row <8) + { + *PORTB_CTRL = 0xAAAA ^ smask; + *PORTM_CTRL = (*PORTM_CTRL & 0xFF00 ) | 0x00AA; + delay(); + *PORTB = cmask; + *PORTM = (*PORTM & 0xF0 ) | 0x0F; + } + else + { + *PORTB_CTRL = 0xAAAA; + *PORTM_CTRL = ((*PORTM_CTRL & 0xFF00 ) | 0x00AA) ^ smask; + delay(); + *PORTB = 0xFF; + *PORTM = (*PORTM & 0xF0 ) | cmask; + } + delay(); + result = (~(*PORTA))>>column & 1; + delay(); + *PORTB_CTRL = 0xAAAA; + *PORTM_CTRL = (*PORTM_CTRL & 0xFF00 ) | 0x00AA; + delay(); + *PORTB_CTRL = 0x5555; + *PORTM_CTRL = (*PORTM_CTRL & 0xFF00 ) | 0x0055; + delay(); + + return result; +} + +unsigned char key_down(unsigned char code) +{ + unsigned short key[8]; + const unsigned short* keyboardregister = (unsigned short*)0xA44B0000; + + if(isOS2) + { + unsigned char row = code%10; + memcpy(&key, keyboardregister, sizeof(unsigned short) << 3); + + return (0 != (key[row >> 1] & 1 << code / 10 - 1 + ((row & 1) << 3))); + } + else + { + return CheckKeyRow((code % 10) + ((code / 10 - 1) << 4)); + } +} diff --git a/otherlib/input.h b/otherlib/input.h new file mode 100644 index 0000000..0be9fdf --- /dev/null +++ b/otherlib/input.h @@ -0,0 +1,108 @@ +/****************************************************************************/ +/* */ +/* Input */ +/* */ +/* Par NineStars V2 */ +/****************************************************************************/ + +#ifndef DEF_INPUT +#define DEF_INPUT + + + +// input_update : mets à jour le clavier, il faut appeler cette méthode une fois par frame +void input_update(); + +// input_press : renvoie 1 si la touche key est pressée, 0 sinon +int input_press(char key); + +// input_trigger : renvoie 1 au moment où key est pressée, 0 sinon +int input_trigger(char key); + +// input_release : renvoie 1 au moment où key est relachée, 0 sinon +int input_release(char key); + +// input_hold_short : renvoie 1 si la touche a été pressée un court instant, 0 sinon +int input_hold_short(char key); + +// input_hold_long : renvoie 1 si la touche a été pressée un long instant, 0 sinon +int input_hold_long(char key); + +// input_repeat : renvoie 1 quand la touche est pressée, puis des 1 à intervalle régulier +int input_repeat(char key); + +// input_reapeat_short : renvoie 1 quand la touche est pressée, puis des 1 à intervalle régulier courts +int input_repeat_short(char key); + +// input_dir4 : renvoie un nombre donnant la direction des touches fléchées suivant l'ordre du pavé numérique +// sans prendre en compte les diagonales, 0 si aucune direction +int input_dir4(); + +// input_dir8 : renvoie un nombre donnant la direction des touches fléchées suivant l'ordre du pavé numérique +// en prenant en compte les diagonales, 0 si aucune direction +int input_dir8(); + +int input_any_key(); + + + + + +void key_inject(int keycode); +unsigned char key_down(unsigned char code); + +/***************/ +/** Key codes **/ +/***************/ +#define K_0 71 +#define K_1 72 +#define K_2 62 +#define K_3 52 +#define K_4 73 +#define K_5 63 +#define K_6 53 +#define K_7 74 +#define K_8 64 +#define K_9 54 +#define K_DP 61 +#define K_EXP 51 +#define K_PMINUS 41 +#define K_PLUS 42 +#define K_MINUS 32 +#define K_MULT 43 +#define K_DIV 33 +#define K_FRAC 75 +#define K_LPAR 55 +#define K_RPAR 45 +#define K_COMMA 35 +#define K_STORE 25 +#define K_XTT 76 +#define K_LOG 66 +#define K_LN 56 +#define K_SIN 46 +#define K_COS 36 +#define K_TAN 26 +#define K_SQUARE 67 +#define K_POW 57 +#define K_EXE 31 +#define K_DEL 44 +#define K_AC 32 +#define K_FD 65 +#define K_EXIT 47 +#define K_SHIFT 78 +#define K_ALPHA 77 +#define K_OPTN 68 +#define K_VARS 58 +#define K_UP 28 +#define K_DOWN 37 +#define K_LEFT 38 +#define K_RIGHT 27 +#define K_F1 79 +#define K_F2 69 +#define K_F3 59 +#define K_F4 49 +#define K_F5 39 +#define K_F6 29 +#define K_MENU 48 + +#endif diff --git a/src/Components/Animation.cpp b/src/Components/Animation.cpp new file mode 100644 index 0000000..e4729cc --- /dev/null +++ b/src/Components/Animation.cpp @@ -0,0 +1,118 @@ +/* ************************************************************************** */ +/* _____ */ +/* Animation.cpp | ___| _ ____ ___ */ +/* Project : C-Engine | |_ | | | __| / _ \ */ +/* | _| | | | |= | __/ */ +/* By: Fife |_| |_| |_| \___| */ +/* */ +/* */ +/* ************************************************************************** */ + +#include "..\Rework\include\Components\Animation.hpp" + + Animation::Animation() + { + TabSprite = NULL; + + nb_image = 0; + delay = 0; + iterateur = 0; + time = 0; + + waitatend = false; + waittheend = false; + isend = false; + } + + Animation::Animation(Sprite & v) + { + TabSprite = &v; + nb_image = 1; + } + + Animation::Animation(Sprite * v , int nb , int nbd , bool vwaitatend , bool vwaittheend) + { + TabSprite = v; + nb_image = nb; + delay = nbd; + + waitatend = vwaitatend; + waittheend = vwaittheend; + } + + void Animation::SetIt(int v) + { + iterateur = v; + time = RTC_getTicks(); + isend = false; + } + + int Animation::GetSizeY() + { + return TabSprite[iterateur].GetSizeY(); + } + + int Animation::GetSizeX() + { + return TabSprite[iterateur].GetSizeX(); + } + + int Animation::GetBlitX() + { + return TabSprite[iterateur].GetBlitX(); + } + + int Animation::GetBlitY() + { + return TabSprite[iterateur].GetBlitY(); + } + + + void Animation::DrawAnim ( int x , int y , int d) + { + if( iterateur >= nb_image) iterateur = 0; + + TabSprite[ iterateur ].DrawSprite( x , y , d); + + if(WaitDelay())iterateur ++; + + if( iterateur >= nb_image) + { + isend = true; + + if(!waitatend)iterateur = 0; + else iterateur = nb_image - 1; + } + + } + + void Animation::DrawReverseAnim ( int x , int y , int d) + { + if( iterateur >= nb_image) iterateur = 0; + + TabSprite[ iterateur ].DrawReverseSprite( x , y , d); + + if(WaitDelay())iterateur ++; + + if( iterateur >= nb_image) + { + isend = true; + + if(!waitatend)iterateur = 0; + else iterateur = nb_image - 1; + } + } + + bool Animation::WaitDelay() + { + + if(RTC_getTicks() - time > (delay / 7.8125)) // si il s'est écoulé une seconde complète + { + time = RTC_getTicks(); // et on se rappelle du nombre de ticks de la dernière seconde écoulée + return true; + } + + return false; + + } + diff --git a/src/Components/Render.cpp b/src/Components/Render.cpp new file mode 100644 index 0000000..be5b751 --- /dev/null +++ b/src/Components/Render.cpp @@ -0,0 +1,146 @@ +/* ************************************************************************** */ +/* _____ */ +/* Render.cpp | ___| _ ____ ___ */ +/* Project : C-Engine | |_ | | | __| / _ \ */ +/* | _| | | | |= | __/ */ +/* By: Fife |_| |_| |_| \___| */ +/* */ +/* */ +/* ************************************************************************** */ + +#include "..\Rework\include\Components\Render.hpp" + + Render::Render(Object * Pointeur) + { + Conteneur = Pointeur; + TabAnim = NULL; + nb_anim = 0; + + iterateur = 0; + + reverse = false; + direction = 0; + + copie = false; + + } + + Render::~Render() + { + if(copie)delete TabAnim; + } + + void Render::SetRender(Animation * v, int nb) + { + TabAnim = v; + nb_anim = nb; + } + + void Render::SetRender(Animation & v) + { + TabAnim = &v; + nb_anim = 1; + } + + void Render::CopieRender(Animation * v, int nb) + { + TabAnim = new Animation[nb]; + + for(int i = 0; i < nb ; i++) + { + TabAnim[i] = v[i]; + } + + nb_anim = nb; + copie = true; + } + + void Render::CopieRender(Animation & v) + { + TabAnim = new Animation; + + TabAnim[0] = v; + + nb_anim = 1; + copie = true; + } + + void Render::SetIt(int v) + { + /*if(iterateur != v && (!TabAnim[iterateur].GetWaittheEnd() || TabAnim[iterateur].GetisEnd())) + {*/ + iterateur = v; + TabAnim[ iterateur].SetIt(0); + // } + } + + int Render::GetIt() + { + if(TabAnim)return iterateur; + + return 0; + } + + void Render::ReverseRender(bool v) + { + reverse = v; + } + + bool Render::GetReverse() + { + return reverse; + } + + void Render::SetDirection(int v) + { + direction = v; + + if(direction > 360) direction -= 360; + if(direction < 0) direction += 360; + } + + int Render::GetDirection() + { + return direction; + } + + int Render::GetSizeY() + { + if(TabAnim)return TabAnim[iterateur].GetSizeY(); + + return 0; + } + + int Render::GetSizeX() + { + if(TabAnim)return TabAnim[iterateur].GetSizeX(); + + return 0; + } + + int Render::GetBlitX() + { + if(TabAnim)return TabAnim[iterateur].GetBlitX(); + + return 0; + } + + int Render::GetBlitY() + { + if(TabAnim)return TabAnim[iterateur].GetBlitY(); + + return 0; + } + + void Render::DrawObject() + { + if(TabAnim) + { + if( iterateur >= nb_anim) iterateur = 0; + + if(!reverse) + TabAnim[ iterateur].DrawAnim( Conteneur->GetTransform()->GetRelativeX() , 64 - Conteneur->GetTransform()->GetRelativeY() - GetSizeY() , direction); + else + TabAnim[ iterateur].DrawReverseAnim( Conteneur->GetTransform()->GetRelativeX() , 64 - Conteneur->GetTransform()->GetRelativeY() - GetSizeY() , direction); + } + } diff --git a/src/Components/RigiBodys.cpp b/src/Components/RigiBodys.cpp new file mode 100644 index 0000000..e2b24e1 --- /dev/null +++ b/src/Components/RigiBodys.cpp @@ -0,0 +1,216 @@ +/* ************************************************************************** */ +/* _____ */ +/* RigidBody.cpp | ___| _ ____ ___ */ +/* Project : C-Engine | |_ | | | __| / _ \ */ +/* | _| | | | |= | __/ */ +/* By: Fife |_| |_| |_| \___| */ +/* */ +/* */ +/* ************************************************************************** */ + +#include "..\Rework\include\Components\RigidBody.hpp" + + RigidBody::RigidBody(Object * Pointeur) + { + usefixebody = false; + widht = 0; + height = 0; + + Conteneur = Pointeur; + + R_body.transform = Conteneur->GetTransform(); + + R_body.velocity.x = 0; + R_body.velocity.y = 0; + + R_body.acceleration.x = 0; + R_body.acceleration.y = 0; + + R_body.mass_data.mass = 0; + R_body.mass_data.inv_mass = 0; + } + + void RigidBody::SetMass(float v) + { + R_body.mass_data.mass = v; + + if(v) + R_body.mass_data.inv_mass = 1 / v; + else + R_body.mass_data.inv_mass = 0; + } + + void RigidBody::UseFixeBody(int w , int h) + { + usefixebody = true; + widht = w; + height = h; + } + + void RigidBody::UseFlexBody() + { + usefixebody = false; + widht = 0; + height = 0; + } + + int RigidBody::GetHeight() + { + return height; + } + + int RigidBody::GetWidht() + { + return widht; + } + + bool RigidBody::GetStat() + { + return usefixebody; + } + + Body * RigidBody::GetBody() + { + return &R_body; + } + + void RigidBody::AppliedForce() + { + if(R_body.mass_data.mass > 0) + { + R_body.acceleration.x = R_body.force.x * R_body.mass_data.inv_mass + R_body.acceleration.x; + R_body.acceleration.y = R_body.force.y * R_body.mass_data.inv_mass + R_body.acceleration.y; + + R_body.velocity.x = R_body.velocity.x + (R_body.acceleration.x * 0.1); + R_body.velocity.y = R_body.velocity.y + (R_body.acceleration.y * 0.1); + + Move(R_body.velocity.x * 0.1, R_body.velocity.y * 0.1); + + R_body.force.x = 0; + R_body.force.y = 0; + R_body.acceleration.x = 0; + R_body.acceleration.y = 0; + } + } + + int RigidBody::Move(int x,int y) + { + if (TryMove( x, y))return 1; + + Affine(x,y); + + return 0; + } + + int RigidBody::TryMove( int x ,int y) + { + /*Map * m = Conteneur->GetEngine()->GetMap(); + + if(!m) + { + int tx = R_body.transform->GetX() + x; + int ty = R_body.transform->GetY() + y; + + R_body.transform->SetXY( tx , ty); + + return 1; + } + + if (x >= m->LARGEUR_TILE|| y>= m->HAUTEUR_TILE) + { + TryMove( x / 2 , y / 2 ); + TryMove( x / 2 , y / 2 ); + return 1; + }*/ + + int tx = R_body.transform->GetX() + x; + int ty = R_body.transform->GetY() + y; + + if (!CollisionDecor( tx , ty)) + { + R_body.transform->SetXY( tx , ty); + return 1; + } + else + { + if( x )R_body.velocity.x = 0 ; + if( y )R_body.velocity.y = 0 ; + } + + return 0; + + } + + int RigidBody::CollisionDecor( int x , int y) + { + /*if(Conteneur->GetEngine()->GetMap()) + { + Map * m = Conteneur->GetEngine()->GetMap(); + + int sizex , sizey; + + if(!usefixebody) + { + sizex = Conteneur->GetRender()->GetSizeX(); + sizey = Conteneur->GetRender()->GetSizeY(); + } + else + { + sizex = widht; + sizey = height; + } + + + if ( x < 0 || ( x + sizex ) > m->nbtiles_largeur_monde * m->LARGEUR_TILE || y + sizey > m->nbtiles_hauteur_monde * m->HAUTEUR_TILE || y < 2) return 1; + + int xmin,xmax,ymin,ymax,i,j,indicetile, hm; + + hm = m->nbtiles_hauteur_monde * m->HAUTEUR_TILE; + + xmin = x / m->LARGEUR_TILE; + ymin = (hm - y - sizey ) / m->HAUTEUR_TILE; + xmax = (x + sizex - 1) / m->LARGEUR_TILE; + ymax = (hm - y -1) / m->HAUTEUR_TILE; + + for( i = xmin ; i <= xmax ; i++ ) + { + for( j = ymin ; j <= ymax ; j++ ) + { + indicetile = m->GetIdMap(i,j); + + if (m->plein[indicetile])return 1; + } + } + + }*/ + + return 0; + } + + + void RigidBody::Affine(int vx,int vy) + { + int i; + + for( i = 0 ; i < abs(vx) ; i++) + { + if ( !TryMove ( sgn(vx) , 0 ) ) + break; + } + + for( i = 0 ; i < abs(vy) ; i++) + { + if ( !TryMove ( 0 , sgn(vy) ) ) + break; + } + } + + + + + + + + + + diff --git a/src/Components/Script.cpp b/src/Components/Script.cpp new file mode 100644 index 0000000..7ae318b --- /dev/null +++ b/src/Components/Script.cpp @@ -0,0 +1,57 @@ +/* ************************************************************************** */ +/* _____ */ +/* Script.cpp | ___| _ ____ ___ */ +/* Project : C-Engine | |_ | | | __| / _ \ */ +/* | _| | | | |= | __/ */ +/* By: Fife |_| |_| |_| \___| */ +/* */ +/* */ +/* ************************************************************************** */ + +#include "..\Rework\include\Components\Script.hpp" + + Script::Script() + { + OConteneur = NULL; + EConteneur = NULL; + } + + void Script::Start() + { + + } + + void Script::Update() + { + + } + + void Script::UpdateEverySecond() + { + + } + + void Script::AffectObject(Object * OV) + { + OConteneur = OV; + } + + void Script::AffectEngine(Engine * EV) + { + EConteneur = EV; + } + + Object * Script::GetObject() + { + return OConteneur; + } + + Engine * Script::GetEngine() + { + if(OConteneur) return OConteneur->GetEngine(); + + return EConteneur; + } + + + diff --git a/src/Components/Sprite.cpp b/src/Components/Sprite.cpp new file mode 100644 index 0000000..56741d7 --- /dev/null +++ b/src/Components/Sprite.cpp @@ -0,0 +1,226 @@ +/* ************************************************************************** */ +/* _____ */ +/* Sprite.cpp | ___| _ ____ ___ */ +/* Project : C-Engine | |_ | | | __| / _ \ */ +/* | _| | | | |= | __/ */ +/* By: Fife |_| |_| |_| \___| */ +/* */ +/* */ +/* ************************************************************************** */ + +#include "..\Rework\include\Components\Sprite.hpp" + + Sprite::Sprite() + { + Alpha = NULL; + Beta = NULL; + + ReverseAlpha = NULL; + ReverseBeta = NULL; + } + + Sprite::Sprite(const unsigned char * v1, int sizex, int sizey , int bx , int by) + { + Beta=v1; + size_x=sizex; + size_y=sizey; + + b_x = bx; + b_y = by; + + Alpha = NULL; + + ReverseAlpha = NULL; + ReverseBeta = NULL; + } + + Sprite::Sprite(const unsigned char * v1, const unsigned char * v2, int sizex, int sizey , int bx, int by) + { + Beta=v1; + Alpha = v2; + + size_x=sizex; + size_y=sizey; + + b_x = bx; + b_y = by; + + ReverseAlpha = NULL; + ReverseBeta = NULL; + } + + void Sprite::DrawReverseSprite( int x , int y , int d) + { + switch(d) + { + case 90: if(size_y % 2 == 0)y --; break; + case 180: if(size_y % 2 == 0)y --; if(size_x % 2 == 0)x --; break; + case 270: if(size_x % 2 == 0)x --; break; + } + + if(ReverseBeta) + { + if(ReverseAlpha) + { + ML_bmp_or_rotate((const unsigned char*) ReverseAlpha, x + br_x, y + br_y, size_x , size_y, d); // Affichage du canal alpha + ML_bmp_and_rotate((const unsigned char*) ReverseBeta, x +br_x, y +br_y, size_x , size_y, d); // Affichage du sprite en entier + } + else + { + ML_bmp_or_rotate((const unsigned char*) ReverseBeta, x +br_x , y +br_y, size_x , size_y , d); // Affichage du sprite en entier + } + + } + else + { + DrawSprite( x , y , d); + } + } + + void Sprite::DrawSprite( int x , int y , int d) + { + switch(d) + { + case 90: if(size_y % 2 == 0)y --; break; + case 180: if(size_y % 2 == 0)y --; if(size_x % 2 == 0)x --; break; + case 270: if(size_x % 2 == 0)x --; break; + } + + if(Beta) + { + if(Alpha) + { + ML_bmp_or_rotate((const unsigned char*) Alpha, x + b_x, y + b_y, size_x , size_y , d); // Affichage du canal alpha + ML_bmp_and_rotate((const unsigned char*) Beta, x +b_x, y +b_y, size_x , size_y ,d); // Affichage du sprite en entier + } + else + { + ML_bmp_or_rotate((const unsigned char*) Beta, x +b_x , y +b_y, size_x , size_y , d); // Affichage du sprite en entier + } + + } + } + + void Sprite::CreateReverse( int brx , int bry) + { + int taille, lx , decalage; + + unsigned char transit; + unsigned char out ; + + br_x = brx; + br_y = bry; + + decalage = size_x % 8; + + lx = size_x / 8 + ( decalage != 0 ); + + taille = lx * size_y; + + if(Beta) + { + ReverseBeta = (unsigned char*) malloc(sizeof(unsigned char) * taille); + + for( int i = 0 ; i < size_y ; i++ ) + for( int a = 0 ; a < lx ; a++ ) + ReverseBeta[i * lx + a] = Beta[ (i + 1) * lx - (a + 1)]; + + for(int i = 0; i < taille ; i++) + { + transit = ReverseBeta[i]; + + out = 0x0; + + if((transit & 0x80) != 0x0) out = out | 0x01; + if((transit & 0x40) != 0x0) out = out | 0x02; + if((transit & 0x20) != 0x0) out = out | 0x04; + if((transit & 0x10) != 0x0) out = out | 0x08; + if((transit & 0x08) != 0x0) out = out | 0x10; + if((transit & 0x04) != 0x0) out = out | 0x20; + if((transit & 0x02) != 0x0) out = out | 0x40; + if((transit & 0x01) != 0x0) out = out | 0x80; + + ReverseBeta[i] = out; + } + + if(decalage) + { + for(int i = 0 ; i < size_y ; i++ ) + for(int a = 0 ; a < lx ; a++ ) + { + transit = ((unsigned char)ReverseBeta[i * lx + a] >> ( decalage)); + + ReverseBeta[i * lx + a] = ((unsigned char)ReverseBeta[i * lx + a] << ( 8 - decalage)); + + if(a != 0)ReverseBeta[i * lx + a - 1] = ReverseBeta[i * lx + a - 1] | transit; + } + + } + } + + + if(Alpha) + { + ReverseAlpha = (unsigned char*) malloc(sizeof(unsigned char) * taille); + + for(int i = 0 ; i < size_y ; i++) + for(int a = 0; a < lx; a++) + ReverseAlpha[i * lx + a] = Alpha[ (i +1)*lx - (a+1)]; + + for(int i = 0; i < taille ; i++) + { + transit = ReverseAlpha[i]; + + out = 0x0; + + if((transit & 0x80) != 0x0) out = out | 0x01; + if((transit & 0x40) != 0x0) out = out | 0x02; + if((transit & 0x20) != 0x0) out = out | 0x04; + if((transit & 0x10) != 0x0) out = out | 0x08; + if((transit & 0x08) != 0x0) out = out | 0x10; + if((transit & 0x04) != 0x0) out = out | 0x20; + if((transit & 0x02) != 0x0) out = out | 0x40; + if((transit & 0x01) != 0x0) out = out | 0x80; + + ReverseAlpha[i] = out; + } + + if(decalage) + { + for(int i = 0 ; i < size_y ; i++ ) + for(int a = 0 ; a < lx ; a++ ) + { + transit = ((unsigned char)ReverseAlpha[i * lx + a] >> ( decalage)); + + ReverseAlpha[i * lx + a] = ((unsigned char)ReverseAlpha[i * lx + a] << ( 8 - decalage)); + + if(a)ReverseAlpha[i * lx + a - 1] = ReverseAlpha[i * lx + a - 1] | transit; + } + + } + + + } + + + } + + int Sprite::GetSizeY() + { + return size_y; + } + + int Sprite::GetSizeX() + { + return size_x; + } + + int Sprite::GetBlitX() + { + return b_x; + } + + int Sprite::GetBlitY() + { + return b_y; + } diff --git a/src/Components/Transforms.cpp b/src/Components/Transforms.cpp new file mode 100644 index 0000000..803d653 --- /dev/null +++ b/src/Components/Transforms.cpp @@ -0,0 +1,66 @@ +/* ************************************************************************** */ +/* _____ */ +/* Transform.cpp | ___| _ ____ ___ */ +/* Project : C-Engine | |_ | | | __| / _ \ */ +/* | _| | | | |= | __/ */ +/* By: Fife |_| |_| |_| \___| */ +/* */ +/* */ +/* ************************************************************************** */ + +#include "..\Rework\include\Components\Transform.hpp" + + Transform::Transform(Object * Pointeur) + { + Conteneur = Pointeur; + + positionabsolu.x = 0; + positionabsolu.y = 0; + + positionrelative.x = 0; + positionrelative.y = 0; + } + + double Transform::GetX() + { + return positionabsolu.x; + } + + double Transform::GetY() + { + return positionabsolu.y; + } + + double Transform::GetRelativeX() + { + return positionrelative.x; + } + + double Transform::GetRelativeY() + { + return positionrelative.y; + } + + void Transform::SetX(double v) + { + positionabsolu.x = v; + } + + void Transform::SetY(double v) + { + positionabsolu.y = v; + } + + void Transform::SetXY(double vx ,double vy) + { + positionabsolu.x = vx; + positionabsolu.y = vy; + } + + void Transform::SetRelativeXY(double vx ,double vy) + { + positionrelative.x = vx; + positionrelative.y = vy; + } + + diff --git a/src/Engine.cpp b/src/Engine.cpp new file mode 100644 index 0000000..cf70e3a --- /dev/null +++ b/src/Engine.cpp @@ -0,0 +1,196 @@ +/* ************************************************************************** */ +/* _____ */ +/* Engine.cpp | ___| _ ____ ___ */ +/* Project : C-Engine | |_ | | | __| / _ \ */ +/* | _| | | | |= | __/ */ +/* By: Fife |_| |_| |_| \___| */ +/* */ +/* */ +/* ************************************************************************** */ + +#include "..\Rework\include\Engine.hpp" + + Engine::Engine() + { + execute = true; + + fps = false; + fpswish = 4; + + listeObject = NULL; + nbobject = 0; + } + + void Engine::StartGame() + { + InitGame(); + + while(execute) + { + ML_clear_vram(); + input_update(); + + ExecuteScript(); + AppliedForce(); + UpdateRelativePosition(); + Draw(); + + setFps(fpswish); + + ML_display_vram(); + } + + DelAllObject(); + } + + void Engine::InitGame() + { + execute = true; + + srand(RTC_getTicks()); + + for( int i = 0 ; i < nbobject ; i++ ) + { + if(listeObject[i]->GetScript() && listeObject[i]->GetEnable())listeObject[i]->GetScript()->Start(); + } + } + + void Engine::StopGame() + { + execute = false; + } + + void Engine::ShowFps() + { + fps = true; + } + + void Engine::HideFps() + { + fps = false; + } + + void Engine::SetFpsWish(int v) + { + fpswish = 180 / v; + } + + void Engine::AddObject( Object * v) + { + Object ** Tab = listeObject; //On créai un pointeur sur la liste actuelle d'objet + + listeObject = (Object**) malloc( sizeof(Object *) * ( nbobject + 1 ) );//On alloue l'espace nécéssaire pour le nouveau tableau + + for( int i = 0 ; i < nbobject ; i++ )//On copie les pointeurs + listeObject[i] = Tab[i]; + + listeObject[ nbobject ] = v; //Et on rajoute l'objet + v->AffectEngine(this); + + nbobject ++; + + delete Tab; + } + + void Engine::DelObject( Object * v) + { + Object ** Tab = listeObject; + int index = -1; + + if(!Tab)return; + + for( int i = 0 ; i < nbobject ; i++ ) + if(Tab[i] == v ) + index = i ; + + if(index == -1)return; + + listeObject = (Object**) malloc( sizeof(Object *) * ( nbobject - 1) ); + + for( int i = 0 ; i < index ; i++ ) + listeObject[ i ] = Tab[ i ]; + + for(int i = index + 1 ; i < nbobject ; i++ ) + listeObject[ i - 1] = Tab[ i ]; + + nbobject --; + delete v; + delete Tab; + } + + void Engine::DelAllObject() + { + for(int i = 0 ; i < nbobject ; i++) + delete listeObject[i]; + + delete listeObject; + listeObject = NULL; + } + + Object ** Engine::GetListeObject() + { + return listeObject; + } + + int Engine::GetNbObject() + { + return nbobject; + } + + void Engine::ExecuteScript() + { + for( int i = 0 ; i < nbobject ; i++ ) + { + if( listeObject[i]->GetEnable()) + if(listeObject[i]->GetScript()) + listeObject[i]->GetScript()->Update(); + } + } + + void Engine::AppliedForce() + { + for( int i = 0 ; i < nbobject ; i++ ) + { + if( listeObject[i]->GetEnable()) + if(listeObject[i]->GetRigidBody()) + listeObject[i]->GetRigidBody()->AppliedForce(); + } + } + + void Engine::Draw() + { + for( int i = 0 ; i < nbobject ; i++ ) + { + if( listeObject[i]->GetEnable()) + if(listeObject[i]->GetRender()) + listeObject[i]->GetRender()->DrawObject(); + } + + if(fps) + PrintV(110,2,getFps()); + } + +/* + bool Engine::WaitOneSecond() + { + if(RTC_getTicks() - time > 128) // si il s'est écoulé une seconde complète + { + time = RTC_getTicks(); // et on se rappelle du nombre de ticks de la dernière seconde écoulée + return true; + } + + return false; + + } +*/ + void Engine::UpdateRelativePosition() + { + for( int i = 0 ; i < nbobject; i++ ) + { + if(listeObject[i]->GetEnable()) + listeObject[i]->GetTransform()->SetRelativeXY( listeObject[i]->GetTransform()->GetX() , listeObject[i]->GetTransform()->GetY() ); + } + } + + + diff --git a/src/Object.cpp b/src/Object.cpp new file mode 100644 index 0000000..dd435b7 --- /dev/null +++ b/src/Object.cpp @@ -0,0 +1,162 @@ +/* ************************************************************************** */ +/* _____ */ +/* Object.cpp | ___| _ ____ ___ */ +/* Project : C-Engine | |_ | | | __| / _ \ */ +/* | _| | | | |= | __/ */ +/* By: Fife |_| |_| |_| \___| */ +/* */ +/* */ +/* ************************************************************************** */ + +#include "..\Rework\include\Object.hpp" + + + Object::Object() + { + OTransform = new Transform(this); + ORender = new Render(this); + tag = new char[20]; + enable = true; + + ORigidBody = NULL; + OScript = NULL; + Conteneur = NULL; + } + + Object::~Object() + { + delete OTransform; + delete ORender; + delete ORigidBody; + delete OScript; + delete []tag; + } + + void Object::AffectEngine(Engine * EV) + { + Conteneur = EV; + } + + void Object::AffectTag(char * v) + { + strcpy( tag , v );//Copie v dans tag. + } + + void Object::Enable() + { + enable = true; + } + + void Object::Disable() + { + enable = false; + } + + void Object::AddRigidBody() + { + ORigidBody = new RigidBody(this); + } + + Engine * Object::GetEngine() + { + return Conteneur; + } + + Transform * Object::GetTransform() + { + return OTransform; + } + + RigidBody * Object::GetRigidBody() + { + return ORigidBody; + } + + Render * Object::GetRender() + { + return ORender; + } + + Script * Object::GetScript() + { + return OScript; + } + + char * Object::GetTag() + { + return tag; + } + + bool Object::GetEnable() + { + return enable; + } + + bool Object::IsOnScreen() + { + /*if(OTransform->GetX() < Conteneur->GetScreen()->max.x && OTransform->GetX() + ORender->GetSizeX() > Conteneur->GetScreen()->min.x && OTransform->GetY() < Conteneur->GetScreen()->max.y && OTransform->GetY() + ORender->GetSizeY() > Conteneur->GetScreen()->min.y ) return true; + else return false;*/ + + return true; + } + + Object * Object::GetObjectCollisionTag( char* v, int x , int y) + { + for( int i = 0; i < Conteneur->GetNbObject(); i++ ) + { + if(Conteneur->GetListeObject()[i] != this) + { + if(!strcmp(Conteneur->GetListeObject()[i]->tag , v) && Conteneur->GetListeObject()[i]->enable) + { + if(Collision(i))return Conteneur->GetListeObject()[i]; + } + } + } + + return NULL; + } + + + bool Object::GetCollisionTag(char* v , int x , int y) + { + if(GetObjectCollisionTag(v,x,y))return true; + + return false; + } + + bool Object::Collision(int id) + { + int widht1 = ORender->GetSizeX(); + int height1 = ORender->GetSizeY(); + int widht2 = Conteneur->GetListeObject()[id]->ORender->GetSizeX(); + int height2 = Conteneur->GetListeObject()[id]->ORender->GetSizeY(); + + if(ORigidBody) + { + if(ORigidBody->GetStat()) + { + widht1 = ORigidBody->GetWidht(); + height1 = ORigidBody->GetHeight(); + } + } + + if(Conteneur->GetListeObject()[id]->ORigidBody) + { + if(Conteneur->GetListeObject()[id]->ORigidBody->GetStat()) + { + widht2 = Conteneur->GetListeObject()[id]->ORigidBody->GetWidht(); + height2 = Conteneur->GetListeObject()[id]->ORigidBody->GetHeight(); + } + } + + if( (( Conteneur->GetListeObject()[id]->OTransform->GetX() + Conteneur->GetListeObject()[id]->ORender->GetBlitX() >= OTransform->GetX() + ORender->GetBlitX() + widht1) + || (Conteneur->GetListeObject()[id]->OTransform->GetX() + Conteneur->GetListeObject()[id]->ORender->GetBlitX() + widht2 <= OTransform->GetX() + ORender->GetBlitX()) + || (Conteneur->GetListeObject()[id]->OTransform->GetY() + Conteneur->GetListeObject()[id]->ORender->GetBlitY()>= OTransform->GetY() + ORender->GetBlitY() + height1) + || (Conteneur->GetListeObject()[id]->OTransform->GetY() + Conteneur->GetListeObject()[id]->ORender->GetBlitY() + height2 <= OTransform->GetY() + ORender->GetBlitY()) + ) == false )return true; + + return false; + } + + +