Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - JpSoft

#141
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

// 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


#142
Quote from: Gepard on Mon 26/05/2008 20:53:09
Thanks a lot. My Gui is now showing a number (finally), but it is showing the wrong number. 46. I dont know why. Here is my script:

// main global script file

    int Skill;
    export Skill;
   
#sectionstart game_start  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() // called when the game starts, before the first room is loaded
  {
    Skill = 0;
  }
#sectionend game_start  // DO NOT EDIT OR REMOVE THIS LINE

#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute()
  {
  // put anything you want to happen every game cycle here
  skillpoints.Text = String.Format("%d", Skill);
}

// Main header script - this will be included into every script in
// the game (local and global). Do not place functions here; rather,
// place import definitions and #define names here to be used by all
// scripts.
   import int Skill;

Check the correction and you will find the mistake   ;)

Jp
#143
I mind that it was not very usefull since its supposed that anyone asking that will try to find the way, and the question was just to know if the answer was "NO" for any already known reason  :)

When i try to run the game, i get a "unknow object schema. Chech out if you spell it correctly" (i dont have the source code here) but I'm sure i follow correctly the intruccions and wrote everything where it must be. I  donwloaded the 1.0.4 version from candle url.

Anycase, i checked the code and i understood that the module is very complete, more than what i need. I just need generate a bird-eye perspective over a plain scenario,it minds, just one animating background (if you have played a RTS game you know what I'm taling about) since a RTS game is already enough heavy for the computer. I get the idea from this module and created a new module which looks can work great (until now only have 30 lines of code). I will upload it soon in case anyone can help me with it, since until now it works perfect with the ground but i still need include objects and characters in the 3D perspective.

Thanks

Jp

EDIT I finally was able to make the module runs, but it do not works for what im looking for anyway  :(
#144
Thanks a lot. Its working perfect now.

Jp
#145
It work perfects! I needed add the code in all the bAnyButton_on_click functions, but now it works fine.

Thanks a lot

Jp
#146
Quote from: Mirek on Sat 24/05/2008 18:44:55
Quote from: JpSoft on Sat 24/05/2008 16:38:05
Anyone knows if this module works with AGS 3.0.0 ??
Give it a try and you will see!   ;)

That is not a usefull answer.

Anyway, i dowloaded it and updated to AGS 3.0.0, but it give me an error with the object schema. I checked the code and it is ok for my understanding. Anyone had this trouble with 3.0.0?

Jp
#147
Anyone knows if this module works with AGS 3.0.0 ??

Jp
#148
Thanks, it works, but i decided continue with AGS 3.0.0 until i finish my current game

Jp
#149
I guess i miss something...Here is the original code, using AGS 3.0.0

Top of GlobalScript.asc

Code: ags
// main global script file

struct ciudades {          
  String nombreciudad;
  int statusciudad;
  int factoryciudad;
  int labciudad;
  int defensaciudad;
  int infanciudad;
  int cabaciudad;
  int asediociudad;
  int Xciudad;
  int Yciudad;
  };

ciudades ciudad[22];
export ciudad;


Top of GlobalScript.ash

Code: ags
// Main header script - this will be included into every script in
// the game (local and global). Do not place functions here; rather,
// place import definitions and #define names here to be used by all
// scripts.
.
.
.
11 import ciudades ciudad[22];
.
.
. 


What i get...

Code: ags
Failed to save room room1.crm; details below
GlobalScript.ash(11): Error (line 11): expected variable or function after import, not 'ciudades'
Failed to save room room100.crm; details below
GlobalScript.ash(11): Error (line 11): expected variable or function after import, not 'ciudades'


What you mind with "Then copy&paste the declaration to the header and put "import" in front of it."? I must repeat the struct declaration in the main header? After or before line 11? Must i add a import line in the room scripts??? (i also tried it and didnt work neither)

Thanks for the sugerence skuttleman, but it looks like a hell to keep the info updated by that way (even when I'm sure it works)

Jp
#150
I have a custom struct declared in the global script

(this is an example since i dont have the source code with me)

Code: ags
struct People_Profile
  {
  string Name;
  int Age;
  bool Sex;
  }


And a array with that struct

Code: ags

People_Profile Humans[50]; 


It works perfect in my global script, so i guess is well implemented. Now what i need is be able to export all this data to every room, since i got an error importing or exporting since AGS ask for a variable or function (it do not recognize People_Profile with imports)

How i can export the array and import it from the room scripts?

Thanks

Jp
#151
I will try with this and let you know. Thanks

Jp
#152
A complete version of the game engine is ready

http://rapidshare.com/files/117223813/AGSWars_Beta_0.2.rar

Updates from last file:
- City GUI will always show in the same position (left down corner)
- Minimap is always visible and clickable (right down corner)
- Difficult level is fully functional (try to beat level 5!!  ;))
- More graphics ripped to give a more profesional aspect.
- Now the game finish when you conquer all citys (still need include final animations and that stuff)
- Left shift added to fast units creation
- Right-click added to attack functions. (still working with right-clicks  :()

Also, the script was simplified to allow the campaigns mode (which will be also included in the final release) and random maps (also in the final release).

What you need know to play this beta:
- LEFT SHIFT + F2 = 10k Gold
- LEFT SHIFT + F3 = 10k Science
- F1 = Show CPU Resources
- LEFT CLICK OVER CITYS = Show the city buildings and status.
- The battle formula have an already know BUG: When you improve your defense a lot, you win free units when fighting (i checked the 100 lines of the formula but i dont find the error so i will wait until i have a better day  :=)

Please, post your C&C and sugerences, thanks.

Jp
#153
Number one...

cNameofCharacter.ChangeRoom(RoomNumber);

Numer two... i believe...

cCharacter.LostInventory(NumberofItem);

I hope it helps, but im sure this very well explained in the AGS help.

Jp
#154
Dinamically use existing .png or .bmp files as walkable areas, or even better, change walkable areas directly from the script (i dont found nothing of that and it could be very usefull to be able to create random rooms).

Jp
#155
Yes, Paul Quest was created using AGS 2.72 and i find the same you say. I really dont pay attention to that since i dont need right clicks in that game, but now i can check that this is a old trouble in the engine.

Jp
#156
Quote from: Mirek CZ on Wed 21/05/2008 18:51:10
Quote from: JpSoft on Wed 21/05/2008 12:36:48
Code: ags
function btnYourButton_Click(GUIControl *control, MouseButton button) {
}

It is script for button with script name "btnYourButton". You have to add script for right mouse button click to every button in your game.

I added it and what i get is the same double result  ??? Looks like by design AGS  ALWAYS process right-clicks over GUIs.

Jp
#157
I just installed AGS 3.0.1 and opened my game with it. First thing i did: press F5 to verify... and i get this...

GlobalScript.ash(12): Unknown preprocessor directive 'DEFINE'
GlobalScript.ash(13): Unknown preprocessor directive 'DEFINE'
GlobalScript.ash(14): Unknown preprocessor directive 'DEFINE'
GlobalScript.ash(15): Unknown preprocessor directive 'DEFINE'
GlobalScript.ash(16): Unknown preprocessor directive 'DEFINE'
GlobalScript.ash(17): Unknown preprocessor directive 'DEFINE'
GlobalScript.ash(21): Unknown preprocessor directive 'DEFINE'
GlobalScript.ash(24): Unknown preprocessor directive 'DEFINE'
GlobalScript.ash(25): Unknown preprocessor directive 'DEFINE'
GlobalScript.ash(26): Unknown preprocessor directive 'DEFINE'
GlobalScript.ash(27): Unknown preprocessor directive 'DEFINE'
GlobalScript.ash(28): Unknown preprocessor directive 'DEFINE'
GlobalScript.ash(29): Unknown preprocessor directive 'DEFINE'
GlobalScript.ash(30): Unknown preprocessor directive 'DEFINE'
GlobalScript.ash(31): Unknown preprocessor directive 'DEFINE'
GlobalScript.ash(32): Unknown preprocessor directive 'DEFINE'
GlobalScript.ash(33): Unknown preprocessor directive 'DEFINE'
GlobalScript.ash(34): Unknown preprocessor directive 'DEFINE'
GlobalScript.ash(35): Unknown preprocessor directive 'DEFINE'

the code of my global script...

Code: ags

#DEFINE mio  1
#DEFINE suyo  2
#DEFINE neutral  3
#DEFINE unknow  0
#DEFINE suyounknow  4
#DEFINE suyoobjetivo  5

// Definir sonidos

#DEFINE m_intro               1


#DEFINE s_ametralladora               1
#DEFINE s_gentehablando               8
#DEFINE s_mardefondo                  3
#DEFINE s_click                       4
#DEFINE s_noclick                     5
#DEFINE s_granclick                   6
#DEFINE s_tanquemoviendo              7
#DEFINE s_otraciudad                  2
#DEFINE s_yescomander                 9
#DEFINE s_ambientevacio              10
#DEFINE s_howmayiserveyou            11
#DEFINE s_ventisca                   12


fisrt line of code is 12 and last 35. I checked the forums and looks like #DEFINE is not remove from AGS. I only read that the demo game can´t be compiled for something like this, but could it be solved or i must replace the definitions?

jp
#158
Quote from: Mirek CZ on Wed 21/05/2008 12:10:21
Yes, you can do that only with scripting.
Code: ags
function btnYourButton_Click(GUIControl *control, MouseButton button) {
 if (Mouse.IsButtonDown(eMouseLeft)) {
   Display("You pressed left mouse button!");
  }
 else if (Mouse.IsButtonDown(eMouseRight)) {
   Display("You pressed right mouse button!");
  }
}


And i must add this function inside rep_exec? It makes no sense for me  ??? This code looks better to check if you are pressing any button(to drag functions, for example) but not to determine which button was clicked.

I added a code on_click when right buttons is pressed over a GUI(just display"right click pressed"), and AGS process the click as left and right (it minds, AGS first pushed the button GUI and then displayed the message  ??? ??? ??? ??? ??? ???

Im sure I'm missing something...

Jp

EDIT Here is the code from my game

in global script...

Code: ags

#sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(MouseButton button) // called when a mouse button is clicked. button is either LEFT or RIGHT
{

if (IsGamePaused() == 1) // Game is paused, so do nothing (ie. don't allow mouse click)
  {
  }
else if (button == eMouseLeft) 
  {
  ProcessClick(mouse.x,mouse.y, mouse.Mode);
  }
else if (button == eMouseRight)// right-click, dont do nothing
  {   
  }
else if (button == eMouseWheelNorth)
  {
  SetViewport (GetViewportX(), GetViewportY()-(scrollspeed*3)); 
  }
else if (button == eMouseWheelSouth)
  {
  SetViewport (GetViewportX(), GetViewportY()+(scrollspeed*3));
  }
}

#sectionend on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE


as you can see, i keep the original coments and leave enough space to make it readable.

Now, what i did was add this single line...

Code: ags
else if (button == eMouseRight)// right-click, dont do nothing
  {   
 Display("Right Click Pressed");
  }


And the game process the click when the cursor is over a GUI and then displays the message. Can i fix this?

#159
I dont have the source code with me (my PC is at home) but i just started the game with the empty template, then just leaved empty the sentences for right click in function on_click (remember that  it changes the mouse mode by default?)

Now, when i right-click in the map, characters or objects, it just dont do nothing; but right-click in any GUI works in the same way like left-clicks (the game is paused or not, i already checked that). Seems like AGS recognize (by default) anyclick over GUIs in the same way (but i guess there is a way to clarify which button you clicked scripting)

Until now, i did not use right clicks in the game, but now i want add special features using right click, but i cant, since when i click in the GUIs, i cant recognize whatever if it was a right or left button.

I hope i was enough clear. If not, i will post the source code tomorrow.

Thanks

Jp
#160
Well, because some stuff i want it working even if the game is paused (scrolling the room, check help files, change options) and other stuff not (is a RTS game, so units cant move when you pause the game, you cant earn money or even move troops)

My fault was that i had all that info mixed and when i founded that i was unable to stop the rep_exec section, i move all the stuff "pausable" into a function called GameInterfaceRuns, which is called everygame cycle from the rep_exec function only when the game is not paused. . I did that just to make more readable the global script since it is very long (+6000 lines until now) but was very tired check all the rep_exec fucnction (as you can imagine, it is really long and complex in a RTS game)

Jp
SMF spam blocked by CleanTalk