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 - Lt. Smash

#81
Wow, this looks amazing! Keep up the good work!

@quo_sp: check your personal messages ;)
#82
Very nice work helios! Another big step forward to AGS 4.0 :)

For OO's sake I would suggest using a new class "Timer".
Like Timer.Set(), Timer.Update()....
By the way it would be cool, if you could "classify" all of the non-object-oriented functions. Like
AbortGame (Game.Abort), AreThingsOverlaping (Room.AreThingsOverlaping), CallRoomScript (Game.CallRoomScript), CDAudio (?), ClaimEvent, CyclePalette (new Palette class perhaps?), Debug (Game.Debug(enum)), DeleteSaveSlot, DisableInterface, FadeIn/Out, FlipScreen, FloatToInt, (lower) game.variables, ...

Keep up the good job ;)
#83
Thanks for the tips guys. Now I've simplified the code some more (first post updated) but it didn't speed up that much.

Some testing results:
[MAP 130x130]
Before: 21 FPS normal, 3-4 FPS when rotating, 9-10 FPS zoomed out to see almost all tiles.
After: 25-26 FPS normal, 11 FPS when rotating, 12-13 FPS zoomed out.

So, as you can see it has improved a bit but there must be a way to get it even faster. (Imagine I'll want to texturize these tiles :o) Maybe some of you clever coders find a way to speed up this lil' thing. (I think it should go way faster, when it would just have to loop through the current visible tiles...)

@Wyz: I can't change the tlX and tlY to ints while calculating because then the map won't rotate that fluently. But afterwards they are stored as ints in the tile array and drawn onto the background.
#84
Hey guys!!

I've been reading the forums and were impressed by the different tile-engines some people have coded using AGS. So I thought, why not trying one by myself, maybe making a game out of it. So I quickly wrote some kind of faked "3d" tile map of which I was, at first, very proud of. (although there are just lines :D) But then I tried to generate larger maps (>60x60 tiles) and the frame drop was very high. With a little tweaking I got it to be a little quicker than before but anyhow, it's way too slow. So, here I am, asking how to improve my code to make it go as fast (least FrameDrop) as possible. I hope you can help me.

Here you can download and try out the tilemap:
TileEngine03 (883 Kbyte)

Keys:
[ N ] - Create new random map with random tilesize
[ Q ] / [ E ] - Rotate map
[ + ] / [ - ] - Zoom in/out map
[ Ctrl ]+[ F ] - Show Framerate
[ G ] - Show floor grid

Code info:
The tiles information is stored in an external file and then loaded into a huge array. Every tile has one height-value (this is the height of the top left corner).
I think the big problem here is, that AGS has to read through the whole array every game loop and that there are so many variables stored in memory.

Here's the code to re-calculate the tiles corner point positions:  // Executed only when rotating the map or zooming in/out
Code: ags

void Map::calculateTiles() {
	// Tile X/Y position
	int x, y, id;
	float posX, posY, startX, startY, a, b, c = IntToFloat(this.tileSize) * screen.zoom;
	
	if (abs(screen.rotation) > 90.0) { // mirror map when rotation is between +-90.0 and +-180.0
		screen.mirrored = true;
	}
	else {
		screen.mirrored = false;
	}
	
	// calculate sides a and b of a triangle (trigonometry)
	a = Maths.Sin(Maths.DegreesToRadians(screen.rotation)) * c;
	b = Maths.Sqrt(c * c - a * a);	
	if (screen.mirrored) {
		b = -b;
	}
	
	// Tile Z position (height)
	float tileSizeHalf = c / 2.0;
	float rectDiag = Maths.Sqrt(tileSizeHalf*tileSizeHalf + tileSizeHalf*tileSizeHalf);
	float rectAngle = Maths.ArcTan2(tileSizeHalf, tileSizeHalf);
	float rot = Maths.DegreesToRadians(screen.rotation);
	
	float tlX = (-rectDiag) * Maths.Cos(rectAngle + rot);
	float tlY = (-rectDiag) * Maths.Sin(rectAngle + rot);
	
	while (x < this.rows) {
		posX = startX;
		posY = startY;
		
		while (y < this.cols) {
			posX += b;
			posY += a;
							
			_tile[id].tlX = FloatToInt(posX + tlX, eRoundNearest);
			_tile[id].tlY = FloatToInt(posY + tlY - _tile[id].z * screen.zoom, eRoundNearest);		
			
			y++;
			id++;
		}
		y = 0;
		x++;

		startX -= a;
		startY += b;
	}
	
}


And here's the drawing code:  // Executed in rep_exec...
Code: ags

void Map::draw(bool drawGround) {	
	int id, t = FloatToInt(IntToFloat(this.tileSize)*screen.zoom);
	drGroundLayer = Room.GetDrawingSurfaceForBackground();
	
	drGroundLayer.Clear();
	drGroundLayer.DrawingColor = 15;
		
	while (id < this.maxTiles) {		
		if (_tile[id].tlX < screen.offsetX - t || _tile[id].tlX > screen.offsetX + System.ScreenWidth + t 
		|| _tile[id].tlY < screen.offsetY - t || _tile[id].tlY > screen.offsetY + System.ScreenHeight + t) {
		}
		else {
		/*	if (drawGround) {
				drGroundLayer.DrawingColor = 11;
				//####
				drGroundLayer.DrawingColor = 15;
			}*/

			if (id == this.maxTiles-1) { } // don't draw last tile
			else if (((id+1) % this.cols) == 0) { // just draw one vertical line for each tile of the last column
				drGroundLayer.DrawLine(_tile[id].tlX - screen.offsetX, _tile[id].tlY - screen.offsetY, 
				_tile[id+this.cols].tlX - screen.offsetX, _tile[id+this.cols].tlY - screen.offsetY);
			}
			else if (id > (this.cols * (this.rows-1) - 1)) { // just draw one horizontal line for each tile of the last row
				drGroundLayer.DrawLine(_tile[id].tlX - screen.offsetX, _tile[id].tlY - screen.offsetY, 
				_tile[id+1].tlX - screen.offsetX, _tile[id+1].tlY - screen.offsetY);
			}
			else { // draw one horizontal and one vertical line for each of the other tiles
				drGroundLayer.DrawLine(_tile[id].tlX - screen.offsetX, _tile[id].tlY - screen.offsetY, 
				_tile[id+1].tlX - screen.offsetX, _tile[id+1].tlY - screen.offsetY);
				drGroundLayer.DrawLine(_tile[id].tlX - screen.offsetX, _tile[id].tlY - screen.offsetY, 
				_tile[id+this.cols].tlX - screen.offsetX, _tile[id+this.cols].tlY - screen.offsetY);
			}
		}
		id++;
	}
	drGroundLayer.Release();
}


Thanks in advance...

[EDIT1] Now it calculates just one point for each tile (so less variables are needed). The tiles to the far right and bottom aren't visible. They just finish up the tiles of the row/column before.
#85
@mode7: The TweenTransparency function would only work if he has downloaded the TweenModule.

If you don't want to do that you can make your own simple FadeIn/Out function:

Code: ags

//Put this in GlobalScript:
void Fade (this GUI*, bool fadeIn)
{
  int t = this.Transparency;
  
  if (fadeIn) {
    while (t >= 0) {
      this.Transparency = t;
      t--;
      Wait(1);
    } 
    this.Clickable = true;
  }
  else {
    while (t <= 100) {
      this.Transparency = t;
      t++;
      Wait(1);
    }
    this.Clickable = false; 
  }
}
// Put this in GlobalHeader:
import void Fade (this GUI*, bool fadeIn=true);

// And then everytime you want to fade your GUI call:
gGuiName.Fade(true); //FadeIn
gGuiName.Fade(false); //FadeOut
#86
Quote from: tzachs on Mon 01/11/2010 18:47:49
Quote from: Ryan Timothy on Mon 01/11/2010 17:16:02
I haven't downloaded this, but if you're working on the Find/Replace, it would be nice if the window didn't take focus. So that you can find a certain keyword, off click from the Find window, edit the line in the script editor and continue with the Find window.

It would be super cool if the window would be at half transparency or something when you're off clicked from it.

That's a nice suggestion, I'll see if I can implement it.
Or (better), like the find window in Firefox, that actually isn't a window, but integrated into the GUI ;)
#87
Yeah for that type of project, git may be the better solution. ;)
Anyway, some kind of versioning system is a must.
#88
I greatly support the idea of using a subversion repository (svn) for interested and capable coders. Otherwise this will end in a complete mess.
#89
so before you open up another topic ;D here is a simple way:

Just go into the on_mouse_click event function of the globalscript and just check for the right mouse button:

Code: ags
[else] if (button == eMouseRight) {  
  gMyGuisName.Visible = true; 
}
#91
First of all you don't need String.Format() if you don't use any variables in the output.
So you can just use:
Code: ags
GUITexto.Text = "New item taken.";


But use String.Format, if f.e. you want to display the items name.
Code: ags
GUITexto.Text = String.Format("%s taken.", item.name);



To answer your question. You need to put this into repeatedly execute:
Code: ags
if(IsTimerExpired(1)) {
  GUITexto.Text = "";
}


And then just call this after you've changed the label text:
Code: ags
SetTimer(1, (5*40)); // 40 loops per second
#92
I always get an error message - it's missing d3dx9_41.dll - when starting the AGS Editor...
#93
Or a Cursor string value, in which you specify a string that should be appended to the end of TextBox.Text. By default "_" but can also be "-", "|-|" or "".
#94
Thanks, that will be very helpful!
#95
Hey! Just wanted to ask if someone could reupload the latest version. The links are dead.
#96
Here I've uploaded the fonts used in FoA: http://www.file-upload.net/download-1910940/fonts.zip.html
Just copy the files into your game folder. If you need special characters you have to use the ttf fonts.
#97
You mean that: http://www.file-upload.net/download-1817781/READMEFOAv2.doc.html (I had the file on my HD)
But remember this template is for AGS v2.61. You'll have to change some code to make it work with never versions.
#98
the best would be if you make 3 or more backgrounds (light to dark) and then fade between them (using transparency settings).
#99
search the manual for activeinv. You will see that it's obsolete and has been replaced by .ActiveInventory.
So replace activeinv with ActiveInventory and do that with all similar errors you probably get.
#100
Either you update the whole code to object-based script or you just set 'Enforce object-based scripting'
and 'Enforce new-style strings' to false (General Settings).
Then you should be able to recompile the rooms. If not, show us what error you get and the wrong code.
SMF spam blocked by CleanTalk