Im creating a module to give a 3D aspect to the scenarios.Its my first module so im sorry if it is not very well explained. Basically, the room need 2 backgrounds, where the 2nd is static (to read the background) and the first one is where the drawing functions works. Its designed for a 640x400 game only, but it could be adjusted with MaxX and MaxY variables.
Code: ags
The trouble is near to the bottom: when i try to assign the resized image to the object[0] (its only for test, later i can add a loop from 0 to object_count) suddenly the object dissapears from the screen. Anyone can help me with this? The X position is not yet adjusted, but it can be easily dome (hopefully)
Here is a link with the source code im working for testing purposes.
http://rapidshare.com/files/117975563/FWars.rar
Wich also have the easy3D module 1.0.4 updated to AGS 3.0
Thanks
Jp
// MODULO Perspectiva
int MaxX = 320;
int MaxY = 200;
int VarianteX, LineaADibujar, Ancho, StartX;
bool EnPantallaX, EnPantallaY, Mostrar;
float zoom, aux;
int zoomint, altura, newwidth, newheight;
function Perspectiva() // Give a deep aspect to the scenario
{
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();
LineaADibujar = 0;
while (LineaADibujar < 200)
{
VarianteX = -40+(LineaADibujar*2/5); // Between -40 y 40
StartX = GetViewportX()+(VarianteX);
if (StartX < 0) StartX = 0;
Ancho = 400-(LineaADibujar*4/5); // Between 400 y 240
if (StartX+400 > 959) StartX = 959-400;
DynamicSprite* sprite = DynamicSprite.CreateFromBackground(1, StartX, GetViewportY()+LineaADibujar, Ancho,1);
surface.DrawImage(GetViewportX(),GetViewportY()+ LineaADibujar, sprite.Graphic, 0, 320, 1);
sprite.Delete();
LineaADibujar++;
}
altura = object[0].Y-GetViewportY(); // Distance to the top
if (altura <= 0) zoom=0.8; // If up of the screen, draw it small
if (altura > 0)
{
zoom = 0.8+(IntToFloat(altura)*0.0076);
if (zoom > 2.5) zoom = 2.5;
}
zoomint = FloatToInt(zoom, eRoundNearest);
if ((object[0].X > GetViewportX()) && (object[0].X < GetViewportX()+319)) EnPantallaX = true;
else EnPantallaX = false;
if ((object[0].Y > GetViewportY()) && (object[0].Y < GetViewportY()+199)) EnPantallaY = true;
else EnPantallaY = false;
if ((EnPantallaX == true) && (EnPantallaY == true)) Mostrar = true;
else Mostrar = false;
if (Mostrar == true)
{
cCharacter.SayBackground ("Object on Screen");
DynamicSprite* sprite = DynamicSprite.CreateFromExistingSprite(object[0].Graphic);
newwidth = FloatToInt(IntToFloat(sprite.Width)*zoom, eRoundNearest);
newheight = FloatToInt(IntToFloat(sprite.Height)*zoom, eRoundNearest);
sprite.Resize(newwidth,newheight);
surface.DrawImage(object[0].X, object[0].Y-newheight, sprite.Graphic);
// Why object[0].Graphic = sprite.Graphic doesnt works??
}
else cCharacter.SayBackground ("Not now");
surface.Release();
}
The trouble is near to the bottom: when i try to assign the resized image to the object[0] (its only for test, later i can add a loop from 0 to object_count) suddenly the object dissapears from the screen. Anyone can help me with this? The X position is not yet adjusted, but it can be easily dome (hopefully)
Here is a link with the source code im working for testing purposes.
http://rapidshare.com/files/117975563/FWars.rar
Wich also have the easy3D module 1.0.4 updated to AGS 3.0
Thanks
Jp