Be a Supporter!
Response to: Mouse to Iso problem Posted December 7th, 2012 in Programming

Let me Retry that:

globalx = localx * (TILE_WIDTH / 2) + localy * (TILE_WIDTH / 2)
globalx - localy * (TILE_WIDTH / 2) = localx * (TILE_WIDTH / 2)
( 2 *globalx /TILE_WIDTH) - localy = localx
				
globaly = localy * (TILE_HEIGHT / 2) - localx * (TILE_HEIGHT / 2) + VERTICAL_OFFSET
globaly - 90 + localx * (TILE_HEIGHT / 2) = localy * (TILE_HEIGHT / 2)
((2*(globaly - VERTICAL_OFFSET)) / TILE_HEIGHT) + localx  = localy
				
localx = (2*globalx / TILE_WIDTH) - ((2*(globaly - VERTICAL_OFFSET)) / TILE_HEIGHT) - localx 
2 * localx = (2*globalx / TILE_WIDTH) - ((2*(globaly - VERTICAL_OFFSET)) / TILE_HEIGHT)
localx = (globalx / (TILE_WIDTH)) - ((globaly - VERTICAL_OFFSET) / (TILE_HEIGHT))
Mouse to Iso problem Posted December 7th, 2012 in Programming

Heya Newgrounds!

Firstly, even though this is written in AS3 (FlashPunk) I figured it belongs on this board, since it is a logic problem and not an language-related problem. If this conclusion is off though, please tell me and I will ask it over at the actionscript board.

So now for the problem:
I am rendering an isometric map in a diamond shape via the following code:

private function renderDiamond():void 
		{
			for (var i:int = 0; i < map.length; i++)
			{
				for (var j:int = map[0].length-1; j >= 0; j--)
				{
					var newTile:Tile = add(new Tile()) as Tile;
					newTile.x = (j * TILE_WIDTH / 2) + (i * TILE_WIDTH / 2);
					newTile.y = (i * TILE_HEIGHT / 2) - (j * TILE_HEIGHT / 2) + VERTICAL_OFFSET;
					newTile.setTile(map[i][j]);
				}
			}
		}

now I want my to compute over which cursor my mouse is currently hovering, So I figured the following maths would do the trick:

globalx 													= localx * (TILE_WIDTH / 2) + localy * (TILE_WIDTH / 2)
				globalx - localy * (TILE_WIDTH / 2) 						= localx * (TILE_WIDTH / 2)
				( 2 *globalx /TILE_WIDTH) - localy 							= localx
				
				globaly 													= localy * (TILE_HEIGHT / 2) - localx * (TILE_HEIGHT / 2) + VERTICAL_OFFSET
				globaly - 90 + localx * (TILE_HEIGHT / 2) 					= localy * (TILE_HEIGHT / 2)
				((2*(globaly - VERTICAL_OFFSET)) / TILE_HEIGHT) + localx  	= localy
				
				localx 														= (2*globalx / TILE_WIDTH) - ((2*(globaly - VERTICAL_OFFSET)) / TILE_HEIGHT) - localx 
				2 * localx 													= (2*globalx / TILE_WIDTH) - ((2*(globaly - VERTICAL_OFFSET)) / TILE_HEIGHT)
				localx 														= (globalx / (TILE_WIDTH)) - ((globaly - VERTICAL_OFFSET) / (TILE_HEIGHT))

but this doesn't work really:

var localMouseX:Number = Input.mouseX / TILE_WIDTH - (Input.mouseY - VERTICAL_OFFSET) / TILE_HEIGHT;
			var localMouseY:Number = (2*(Input.mouseY - VERTICAL_OFFSET)) / TILE_HEIGHT + localMouseX;
			
			localMouseX = Math.floor(localMouseX);
			localMouseY = Math.round(localMouseY);
			
			_pointer.x = (localMouseX * TILE_WIDTH / 2) + (localMouseY * TILE_WIDTH / 2);
			_pointer.y = (localMouseY  * TILE_HEIGHT / 2) - (localMouseX * TILE_HEIGHT / 2) + VERTICAL_OFFSET;

When hovering over tile(0,0) the pointer is over (-3,3). Furthermore, the mouse positions at which the pointer jumps to another tile seem to be off by half the width and height of the tile.

I'm breaking my head over this and I hope someone can shine some light on this issue!

Cheers,
Vadinci

Edges of brick buildings? Posted December 23rd, 2011 in Art

Hey everybody,

Im currently working on some background art for a game me and my "crew" are making. I'm not the greatest artist but I like how it is coming along so far.

Most buildings in our game are build with those old fashioned, huge "bricks" as I call them. It looks pretty neat, but I'm not quite sure how I should do the edges of those buildings.
Any tips?

Also, I have almost only worked on the brick layer so far. All the other things are just base colours and shapes, to have a quick idea of how the total is going to look.

Edges of brick buildings?

Response to: [as3]calling functions / keyCodes Posted November 14th, 2011 in Game Development

That will do the trick, but then I'll have to make a funcion which sole purpose is to call another function if space is pressed. If possible I'd rather had something that could just fit into one function, but if it can't be done I'll probably do it this way.

[as3]calling functions / keyCodes Posted November 14th, 2011 in Game Development

Man the amount of letters you can add in a forum title sure makes it hard to describe something.

Ok, here's the problem. I want a function that is both triggered when I press space or when another function is done doing it's task. This works pretty good:

private function fillText(e:KeyboardEvent = null):void
		{
				stage.removeEventListener(KeyboardEvent.KEY_UP,fillText);
				removeEventListener(Event.ENTER_FRAME, typText);
				speechBox.text = currentText;
				stage.addEventListener(KeyboardEvent.KEY_UP, updateText);
		};

but that way, it will be activated no matter what key I press, while I only want it activated when I press space. But once I add that restriction:

private function fillText(e:KeyboardEvent = null):void
		{
			if (e.keyCode == 32 )
			{
				stage.removeEventListener(KeyboardEvent.KEY_UP,fillText);
				removeEventListener(Event.ENTER_FRAME, typText);
				speechBox.text = currentText;
				stage.addEventListener(KeyboardEvent.KEY_UP, updateText);
				
			}
		};

my other function can't trigger it.

Is there a solution to this or will I need to write two seperate functions? :(


I'm working on a talking system for NPCs, that will show a speech bubble above the NPC's head
with text in it. Said speech bubble will have to vary in height depending on how many lines there are in the textfield. I know about numLines(), obviously it returns the amount of lines in the box, but I'd like to have the text appear letter by letter. That way I won't be able to know how many lines there are going to be when the text is finished.

So my question is: is there a way to figure out how many lines there are going to be in the textbox when it's filled?


It already past judgement with 3/5:

Response to: 60 Frame Collab 4 Posted June 23rd, 2011 in Collaboration

So this is still being worked on?
Is it OK if I give this a shot as well, or am I too late?

Response to: attachMovie [as2] Posted June 22nd, 2011 in Game Development

I know as3 would be a better choice, but I just want to make this game I have in my head now. It's too big of a project to start off in a new language. I'm reading in on as3 though, and I'm like the side-programmer for big projects with the group I'm in. I'll definitely learn it, just not for this project.

The problem is solved BTW. I forgot to export the MC for actionscript -_-

Response to: As2 Platform Game Help! Posted June 22nd, 2011 in Game Development

If you could post the part of the code in which you add to y_factor, it would be a lot easier for other people to help you spot the bug. My guess is that it's just a miscalculation somewhere.

Response to: As2 Platform Game Help! Posted June 22nd, 2011 in Game Development

Oh I see, I thought that was a bug that came along with making the scenery move, my fault.

So you have this value y_factor. When do you raise that and when do you lower it? It seems that
it works fine but that there are some miscalculations there.

By the by, you have a pretty neat looking platformer there, I only think the speed of the player running versus it's jumping speed contrast a lot :/

Response to: As2 Platform Game Help! Posted June 22nd, 2011 in Game Development

So you basically want to move the background to move down when the character goes up, so that it stays aligned with the tiles. I'm guessing right now you move the tiles down aswell when you move up, why can't you apply the same mechanic to your background?

attachMovie [as2] Posted June 22nd, 2011 in Game Development

So my code is failing pretty hard. I'm trying to build a little tile editor for a game I'm about to make, but
in setting up the tiles on the screen something goes wrong.
Here's the code:

for (j = 0; j < _root.mapHeight; j++)
{
	for (i = 0; i < _root.mapWidth; i++)
	{
		var newname:String = "tile" + i + "x" + j + "y";
		var newTile:MovieClip = _root.attachMovie("mcTileInt", newname, _root.makeDepth);
		newTile._x = (i * _root.tileWidth) + _root.editorOffsetX;
		newTile._y = (j * _root.tileHeight) + _root.editorOffsetY;
		trace(newTile._x);
		_root.makeDepth += 1;
	}
}
stop();

the trace just spits a shitload of 'undefined's at me.
I double checked the variables once again just to be sure, and they're all right.
Hope one of you can help me fix this :)