Recent posts by Varilian on Kongregate

Subscribe to Recent posts by Varilian on Kongregate

avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / Resources for making an AS3 compatible socket server?

I really would like to learn more about how socket servers work, how to set them up, etc. While I’m searching, it’s a bit difficult to pick out resources that are useful on a complex topic that I know nothing about.

Does anyone have books/websites/tutorials that they could recommend for making a socket server that is compatible with AS3? I would prefer XML sockets, since I’m already used to MySQL/PHP/XML, but I am willing to learn anything if I save time/money/efficiency.

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / Developing a system of upgrades (Solved)

I figured it was just something to play around with. Just always glad to have a second opinion. Thanks parallactic/Liquid Egg

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / Developing a system of upgrades (Solved)

I know that this is a ‘programming’ forum, but there isn’t a ‘theory’ section.

How do you come up with a good system of upgrading? Increasing difficulties, increasing costs, etc.

I really want to believe that there is more to it all than hit/miss. There must be a practice of what makes a good choice of money earned/money required.

If there are any tips as to how I can get better at difficulties, systems of upgrades/increasing rewards, I would really appreciate it.

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / Custom Events to pass Variables between frames? [AS3]

Just found a nice section in one of my books I haven’t read yet…
If anyone would like to double check me, please reply.

But the way that I see this being done, is to add an eventListener in my Main document class, which listens to the stage for an event that I name (just like every other event). When I catch that event, I can pass the variables that I want to use between frames as parameters.

The Main class will save those variables, and when the next frame loads, a different event will call for those variables, which get returned from the Main class (whose variables don’t change between frames.)

Everything sound okay?

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / Custom Events to pass Variables between frames? [AS3]

I was told that if I wanted to get variables between different frames (without using global variables,) I would have to use custom events.

Now, I am looking them up right now, but I cannot see how this works so far. If anyone would like to direct me to a resource, or explain how, I would greatly appreciate it.

Also, if anyone would like to tell me about their best used resources for studying AS3, that would be helpful. I believe I understand the basic, but cannot begin to study other things. I hear talk of ‘Super’ classes, custom event dispatching, and I know there is a lot that I don’t know…I just can’t figure out where to keep learning.

Hear to answer any questions…Thank you very much!

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / Keeping the Ball in Play? (AS3)

Originally posted by UnknownGuardian:

You will need to keep checking more times just in case the ball happens to get much faster and still pass through under those conditions.

Originally posted by Moonkey:

If you’re comfortable with a little geometry, that would be a far better way to go than hitTesting.

Even using multiple hitTests, you’re still going to get situations where the ball goes across the corner of the paddle without registering a hit, even though it appears to the player that it should have.

At first, I thought that…But even once the x and y velocities get large enough to do that, no player should be able to keep up with the ball….But just in case, I may split it again into 4 seperate tests….Just in case. The game shouldn’t be too memory-intensive on it’s own, so I should be able to afford it.

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / Keeping the Ball in Play? (AS3)

Originally posted by carmensandiago:

if(vx > paddle.width){
_ball.x += vx/2;
checkCollision();
_ball.x += vx/2;
checkCollision();
}

Facepalm self

Thank you…After a bit of fitting it to match my game… it worked very well :D
The only thing I have to mention is that you shouldn’t have “vx>paddle.width.” You only need to start checking when “vx> 2 * paddle.width”. Otherwise, it wouldn’t be possible to go through it!

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / Keeping the Ball in Play? (AS3)

Wow…Been a while since I’ve posted in the forums…

Right now I’ve got a game going, where the main game is….well, Pong. Paddle, ball, etc.

Problem is, the ball can be sped up depending on what the player does…
The movement of the ball is pretty standard….In my enter frame, I have:

vx=5;
_ball.x+=vx;

Or basically something to that effect. If you already see what my problem is…Thank you! But otherwise, continuing…

Let’s say we pick a simple one…And the ball’s speed increases by 1 every time it hits the players’ paddle…

Once it gets to where it’s speed is larger than the width of the walls/paddle…It can go past the paddle/walls, before my hitTests ever return it…

Fixing it going outside the walls was simple… I made so that if it ever went out of the stage, I put it back in, and changed it’s speed to go in the other direction…

But then it passed through the paddle….

I can’t tell if it’s passed by because of super speed, or passed completely through the player…So if I returned it, the player would never die…

I would like to make it so that this ball can go as fast as the player wants…But I can’t think of a solution for when it passes through the paddle…

I can test just about any idea…I have the computer testing the solutions…(Paddle ‘y’ position = ball ‘y’ position, makes for an endless game…)

If you have any ideas, or suggestions, I would appreciate it!

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / Need help with Anticheat on Maze

Originally posted by MaToMaStEr:

add a Mouse Listener, and catch the left clicks. when it’s clicked, make the finish invisible… and make it visible again when the button is up.

var mouseLis:Object = new OBject();
Mouse.addListener(mouseLis);

mouseLis.onMouseDown = function(){
    finish._visible=false;
}
mouseLis.onMouseUp = function(){
    finish._visible=true;
}

add that code on the first lines of the frame where your maze is.

Off topic, but that’s pretty clever : )
I don’t think I’ve ever seen that one before.

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / Scenes AS3

Originally posted by KMAE:

I will try that, I didn’t know the scene was considered attached so closely if that makes sense. I thought in order to get out of one scene to another you had to specifically call it. The play is because it goes right into the intro animation so I don’t want to stop.

Edit: That did not work. Since I had erased the first frame of the second scene thinking it would conflict, calling nextFrame(); just goes to that blank frame and stops. If I call nextFrame(); from there it goes to the first frame of animation and stops. So I have to call play(); to get it started again.

Have you tried calling play(); from the last preloader frame?

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / Scenes AS3

Originally posted by KMAE:

function continueOn():void {
removeEventListener(Event.ENTER_FRAME, preloaderListener);
gotoAndPlay(“intro”, “Poe”);
}

Why do you have a gotoAndPlay?
Try using this instead. If I know how your preloader looks, then this should work just fine.

function continueOn():void {
	removeEventListener(Event.ENTER_FRAME, preloaderListener);
	nextFrame();
}

If that code is in the last frame of your preloader, or a layer that reaches the last frame, your swf will automatically advance to the next scene.
 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / API giving me error #1010 (Solved!)

Finally got it all working!
I put it in the timeline, and everything worked fine.
If anyone else has problems with the AS3 API, I recommend using your frame 1 to load data/API.

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / API giving me error #1010 (Solved!)

I’m going to make a new class for the API. I’ll use the example from the primer.
What I’m wondering is if it matters that I use a preloader in a different scene.

What’s so bad about using the component anyway?

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / Preloader going infinite[AS3]

Originally posted by Cantor:

Why are you using an ENTER_FRAME event type? I have never used that to make a preloader, i have always used the ProgressEvent type and never had any trouble with them.

Try using:

stop();

loaderInfo.addEventListener(ProgressEvent.PROGRESS, loader);

function loader(filename:ProgressEvent):void
{
	//find the file size and convert it to a 1-100% number
	var percent:Number = Math.floor((filename.bytesLoaded*100) /filename.bytesTotal);
	
	//go to the frame number based on the percent loaded 
	if(percent <=99)
	{
		preloader.gotoAndStop(percent);
	}//end of if
	
	//when fully loaded go to the last perloader frame and remove the listener
	else if(percent == 100)
	{
		preloader.gotoAndStop(percent);
		loaderInfo.removeEventListener(ProgressEvent.PROGRESS, loader);
                nextBtn.x = 275;
	}//end of else if
	
};

That should work. As i said, it never fails for me.

If I have to, I will use that. But for some reason, I switched to using a preloader in a different scene, and the problem fixed itself.

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / API giving me error #1010 (Solved!)

Originally posted by SuperMarioJump:

And when you set the document class in the properties toolbar it didn’t give you a warning like “Class cannot be found, will be created at runtime”?

No, I didn’t get an error. Also, I made the class before setting it as the main class, and made sure it was in the root project folder.

Creating a new post instead of editing because this might be important.
I get this error:

TypeError: Error #1010: A term is undefined and has no properties.
	at scoreButton()[C:\Documents and Settings\(Censored)\My Documents\Flash Design\API Test\scoreButton.as:20]

I get it when I originally try to submit a score.
So I deleted that line. Then I got it when I clicked the button (line 28)
Which raises another problem. It’s the kongregate.stats.submit piece of code that’s causing the error, but the last time it’s in there (API load complete) it doesn’t throw an error.

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / API giving me error #1010 (Solved!)

Originally posted by SuperMarioJump:

Are you really sure it’s set as the main class? If it’s not tracing “Initialized” either you don’t have the debug Flash Player or you’re not comiling this class.

I don’t know which flash program you use, but I use CS4. So all I do is click the first frame, go to the properties toolbar, and I can edit the main document class.

I do find it weird that it wasn’t initializing when it was the main class.

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / Adding things dynamically

Originally posted by Gamepages:

I’d highly recommend not drawing it like that. use a movieclip.

Drawing it like that is less memory-intensive, and is better when it’s scaled.

Anyone can correct me if I’m wrong, but isn’t he better off drawing it like this?

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / API giving me error #1010 (Solved!)

Sorry I took so long. I hope someone’s reading this.
But it’s set as the main document class. Does this need to be instantiated as an object or something?

Edit:
I added it to the Button on the stage, and I got my first trace (the class is created)
But there’s no API traces, and the button doesn’t trace anything when it’s clicked.

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / API giving me error #1010 (Solved!)

package
{
	import flash.display.*;
	import flash.events.*;
	import flash.media.Sound;
	import flash.net.URLRequest;
	import flash.system.Security;

	public class Main extends MovieClip
	{
		public var kongregate:*
		var paramObj:Object = LoaderInfo(root.loaderInfo).parameters;
		var apiPath:String = paramObj.kongregate_api_path || 
		"http://www.kongregate.com/flash/API_AS3_Local.swf";
		public var three:int=3;
		
		public function Main()
		{
			trace("Initialized");
			kongregate.stats.submit("score", three);
			Security.allowDomain(apiPath);
			scoreBtn.addEventListener(MouseEvent.MOUSE_UP,clicked);
		}
		
		private function clicked(e:MouseEvent)
		{
			kongregate.stats.submit("score", three);
			trace("Score Submitted");
		}
		
		public function loadAPI()
		{
			var paramObj:Object = LoaderInfo(root.loaderInfo).parameters;
			var api_url:String = paramObj.api_path ||  "http://www.kongregate.com/flash/API_AS3_Local.swf";
			var request:URLRequest = new URLRequest ( api_url );
			var loader:Loader = new Loader();
			loader.contentLoaderInfo.addEventListener ( Event.COMPLETE, apiLoadComplete );
			loader.load ( request );
			this.addChild ( loader );
			trace("API loaded");
		}
		
		public function apiLoadComplete( event:Event ):void
		{
			kongregate = event.target.content;
			kongregate.services.connect();
			kongregate.stats.submit("score", three);
			trace("Load Complete");
		}
	}
}

Is there any reason why this shouldn’t work?
When I test it locally, the Main class doesn’t trace anything, even when I click the button.
When I test it on the site, I get the green light, but no score submission.

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / External Preloader vs. Kong API

Originally posted by SuperMarioJump:

I think you just have to connect to the API in the preloader, then find a way to communicate with the preloader from your game swf. Otherwise you could switch to FlashDevelop which has simple preloading.

If anyone can confirm this, I’m guessing that means communicating with the preloader SWF with public, static functions?

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / External Preloader vs. Kong API

The problem can be found at http://www.kongregate.com/forums/4-programming/topics/5564-problem-with-highscore-api

But if you don’t want to read it, the idea is that you can’t use an external preloader on Kong, because the Kong API needs to be used in your Main swf. If you’re trying to load a game, it makes sense that your main .swf would be the preloader.

Anyone can correct me if I’m wrong, but if I use an external preloader, then how can I submit the game with the Kong API implemented!

Also, if I can’t use an external preloader, how am I supposed to load a game? I’ve tried everything. Frame 2 and 3 versions of preloaders, new scene preloaders, and anything else I can find.

I have a brand new FLA that is empty except for a bunch of .png files to take up space on the stage. I would really appreciate it if someone could tell me how to load this thing!

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / Preloader going infinite[AS3]

The title says it all.
When I start my game up on my pc, it loads to 100%. shows the correct loaded/total bytes, and the animation works.
When I upload it to SWFCabin, I get infinite %, and 0 bytes to load.

I tried adding:

if(toLoad==0)
{
    toLoad=1;
}

To the code, but to no avail.

Full code, all children/dynamic textfields are appropriately named.

stop();

stage.addEventListener(Event.ENTER_FRAME, loader);
nextBtn.tabEnabled=false;
nextBtn.addEventListener(MouseEvent.MOUSE_UP,clicking);

function clicking(e:MouseEvent)
{
	gotoAndPlay(2);
}

function loader(e:Event):void
{
	var toLoad:Number = stage.loaderInfo.bytesTotal;
	var loaded:Number = stage.loaderInfo.bytesLoaded;
	var total:Number = loaded/toLoad;
	if(toLoad==0){toLoad=1;}
	if(loaded >= toLoad)
	{
		preloader.gotoAndStop(Math.floor(total*100));
		preloader.percentBytes.text=Math.floor(total*100) + "%";
		preloader.currentBytes.text=""+loaded;
		preloader.totalBytes.text =""+toLoad;
	
		removeEventListener(Event.ENTER_FRAME, loader);
		nextBtn.x=275;
	} 
	else 
	{
	preloader.gotoAndStop(Math.floor(total*100));
	preloader.percentBytes.text=Math.floor(total*100) + "%";
	preloader.currentBytes.text=""+loaded;
	preloader.totalBytes.text =""+toLoad;
	}
}

All objects are set to export on frame 2.
Thanks as usual!

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / Shared Objects [AS3]

Originally posted by DeepClaw:

you may add a number to flush:

  so.flush(1024);

That way you could make public functions to read your SharedObject.
Only open the SharedObject once in your class and use the function to access it:

readString(name:String):String {
  return so.data[name];
}

I looked at the livedocs, and that number is supposed to be the ‘minimum disk space.’
How do I determine what number I need that to be? How does that speed up progress?
Can you give me a good example of that last function?
Sorry for all the questions!

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / Shared Objects [AS3]

If anyone can’t answer that, I have one more question.
If I test my project, and I have Shared Objects being saved, where will Flash save them?

 
avatar for Varilian Varilian 92 posts
Flag Post

Topic: Game Programming / Shared Objects [AS3]

I was looking at my game, and realized I haven’t done anything with Shared Objects! I knew they were a necessity, so started looking around the web to see what I could find as information.

Correct this if it is wrong, if anyone wouldn’t mind.

//To write data
import flash.net.SharedObject;
var so:SharedObject = SharedObject.getLocal("userData");
so.data.username= "user1377";
so.data.pwdhash= "[hash] or pwd";
so.flush(); // writes changes to disk

//To load data
import flash.net.SharedObject;
var so:SharedObject = SharedObject.getLocal("userData");
var username:String = so.data.username;
var pwdhash:String = so.data.pwdhash;

Is this all there is to it? I understand you need to have your variables ready, and put this code in the appropriate places. But is this all there is to Shared Objects?

If anyone has a better tutorial, I would appreciate it.