Recent posts by tonikovacic on Kongregate

Flag Post

Topic: Game Programming / [AS3] Displaying Text With Code

make new TextField variable, add it with addChild method. TextField have text property, that is text that it will be displayed.

 
Flag Post

Topic: Game Programming / Show us a screenshot of what you're working on!

User interface for my new game, what do you think?

level select:

main menu:

 
Flag Post

Topic: Game Programming / sound volume changing on its own

here is how i do it, i have static class SoundAsset from which sounds can be played, so i can request playback from anywhere in code:


public static var soundTransform1:SoundTransform = new SoundTransform(0.05, 0);
		public static var soundTransform2:SoundTransform = new SoundTransform(1, 0);
		public static var soundMixer:SoundMixer = new SoundMixer();
		
		private static var channel1:SoundChannel = new SoundChannel();
		private static var channel2:SoundChannel = new SoundChannel();
		public static var channels:Vector.<SoundChannel> = new Vector.<SoundChannel>([channel1, channel2]);
		
		public static function PlaySound(sound:Sound, transform:SoundTransform = null, channel:int = 0):void
		{
			channels[channel] = sound.play(0, 0, transform);
			trace(channels);
		}

It looks like soundchannels are sharing volume from total amount of 1, but i traced every possible property of soundtransform on channels. also if ratio between 2 soundchannels is small (1 and 0.1) volume reduction is also smaller. that leads me to think that volume is shared. But that is very weird, what is way around this? how do you guys usually handle multiple sounds and effects in game?

 
Flag Post

Topic: Game Programming / sound volume changing on its own

http://www.newgrounds.com/dump/item/2614041ec4cea7ae25d492d7 2315f395

I asked on ng, and i will ask you.

I have 2 soundChannels in 2 different class
one is “theme” and other is “footsteps”
theme starts running, everything is fine
when player start to move and footsteps start to play, themes volume is reduced
i traced every properties of theme.soundTransform and nothing is changed… i dont get it
any suggestions?

is it possible that all sounds share 100% of volume, and if 1 channel plays at 0.7 other at 0.7 that both volumes get reduced to 0.5, its random thought but thats how it looks

 
Flag Post

Topic: Game Programming / Trying to shoot from the hand of my character. Need a formula

hmmm try double checking registration points, and see how is code related to them

 
Flag Post

Topic: Game Programming / Classes and keyboard

for example, you are running game @30 fps, and you got drop in frame rate to 15 fps, timer event will still trigger every 30ms but frame will be drawn every 60ms, and in 1 frame your “frame code” will be triggered twice, its just safety measure for me.

 
Flag Post

Topic: Game Programming / Classes and keyboard

Also may i recommend not using timer event for game loop. It’s better using enter_frame event

 
Flag Post

Topic: Game Programming / Classes and keyboard

KeyboardEvent is triggered only if, in your case, document class have focus, so trace stage.focus

 
Flag Post

Topic: Game Programming / localToGlobal collision

The thing is that i have my ship which player controls always in middle of screen, so everything else is moving around it, thats why it is in different containers, the thing is that I can check for real coordinates where objects are shown on stage. Actually i figure out how to do this

<per>

e_point = enemies[k].parent.localToGlobal(new Point(enemies[k].x, enemies[k].y));

</per>

this way i got coordinates on stage. Other thing was that ships can rotate, so i have to “reset” hit area rotation, and fix “fake coordinates” of bullets and then check for collision :D thanks for reply, hope this too will help someone

 
Flag Post

Topic: Game Programming / Problems with my simple maze game [Solved]

Piece of advice, dont go as2, its a waste of time. go as3

 
Flag Post

Topic: Game Programming / localToGlobal collision

Im making shooter game, but i stuck at this collision thing…
Here’s the thing. I have Ship.as which is super class of all types of ship, every ship got hit area sprite.
Players ship is child of engine container, and enemy ships are child of Enemy Fleet container which is child of engine


for (var i:int = 0; i < bullets.length; i++)
			{
				for (var k:int = 0; k < enemies.length; k++)
				{
					b = bullets[i];
					e = enemies[k];
					
					
					
					hit = enemies[k].hit_area;
					
					
					
					e_point = localToGlobal(new Point(enemies[k].x, enemies[k].y));
					
					trace("e_point: ", e_point.toString()); // here i get enemy position but apparently from Enemy fleet container
					
					trace("global hit area: ", localToGlobal(new Point(enemies[k].hit_area.x, enemies[k].hit_area.y))); // here i get x = 50, y = 0, and thats hit area position inside of ship, not very usable
					
					trace("hit area rect: ", getRect(enemies[k].hit_area).toString()); // here is x = some x, y = some y w=11350, h=11850, and this width and height are dimension of whole stage, with objects n sutff...
					
					if (b.x > e_point.x && b.x < e_point.x + hit.width && b.y > e_point.y && b.y < e_point.y + hit.height)
					{
						removeChild(b);
						bullets.splice(i, 1);
						ship.bullets = bullets;
					}
				}
			}

so is there any way around this, i tried everything, but nothing seems to work…

 
Flag Post

Topic: Game Programming / How to use preloader

Let’s say i have 2 .fla, one is my game second is preloader, so i have 2 SWF, when i test preloader.swf locally it works, but how can i make it to work when uploaded on internet?

 
Flag Post

Topic: Game Programming / Array tile map and tiles properties

Hello community.
I am in process of making prototype for a new game. I am using tile based map system, so i have array 20×15 which represent map, 0 is floor, 1 is wall, 2 is laser, 3 are doors, etc..
My question is how can i edit parameter of each tile in a way that they are represented in array map. Should I use object for tile properties or there is better way?
I want to achieve that my tiles are customizable so that i can have some lasers thar can rotate and some that cant, etc…

 
Flag Post

Topic: Game Programming / How to use preloader

Why on earth would you use urlloader?? Just export all classes in frame 2, and put loader in frame 1

 
Flag Post

Topic: Technical Support / Not published

I uploaded game first time on kong today but game is not published, where to go from here?

 
Flag Post

Topic: Game Programming / [AS3] Collision detection?

you can use either hitTestObject, wich checks collision of bounding boxes of display object, or you can use hitTestPoint wich checks if there is any pixel collision. You would have to put all objects in array. example if you have enemy army create array called army and put all enemies in that array, then check for collision within that array against any object you whant, for bullets same, create bullets:Array and put all created bullets there.
then you will probably whant to check collision between your bullets and enemies, easy. for (var a:int = 0; a < army.length; a++) { for (var b:int = 0; b < bullets.length; b++) if(army[a].hitTestPoint(bullets[b].x, bullets[b].y, true)) { //destroy enemy
}}}

 
Flag Post

Topic: Game Programming / Actionscript 3 and graphic tips?

you can’t call frames of individual layers because all layers are being played in same time, if i understood question correctly.