Recent posts by Draco18s on Kongregate

Flag Post

Topic: Game Programming / [AS3] creating multiple instances of a movieclip on the stage and dynamic instance names [SOLVED]

var myMC:MovieClip = /*get from library*/
myMC.name = "whatever the hell you want" 

See also http://www.republicofcode.com/tutorials/flash/as3loops/

 
Flag Post

Topic: Game Programming / questions about moving objects with delta time.

Imagine inlining that function:

var timePassed:int;

timePassed = getTimer() - lastTime;
lastTime += timePassed;
this.x += speedX * timePassed/1000;

timePassed = getTimer() - lastTime;  //what do you think happens here?
lastTime += timePassed;
this.y += speedY * timePassed/1000;
 
Flag Post

Topic: Game Programming / questions about moving objects with delta time.

Whatever it is, its not part of the scripts you have posted. In the code you have posted, you haven’t called SetNewXSpeed (or YSpeed) anywhere.

 
Flag Post

Topic: Game Programming / Proc Jam

Thought I’d forward this along.

http://itch.io/jam/procjam

It’s a game jam…thing involving procedural generation. Make stuff that makes other stuff.

 
Flag Post

Topic: Game Programming / Couple of questions about UDK

-I noticed that Kong doesn’t support UDK games, Is there any chance that will change? If so, when? If not, why?

Because UDK doesn’t support web plublishing and has no plans to.

 
Flag Post

Topic: Game Programming / Troubles with Array lenght!

I learned the power of enums when Minecraft modding. Then found that C#/unity did not have enums that were that powerful, so I’m faking it like you’d have to do in AS3:

using UnityEngine;
using System.Collections.Generic;

public class EElement {
	public List<EElement> goodAgainst;
	public Color primary;
	public Color secondary;
	public Color tertiary;
	public float glowRatio;
	public float glowBoost;
	private string elemName;
	
	public static EElement EARTH = new EElement(SPIRIT, "EARTH", 	new Color(.215f,.392f,0f), new Color(.4f,.278f,.117f), new Color(.157f,.294f,.647f), .3f, 0.05f);
	public static EElement AIR = new EElement(EARTH, "AIR", 	new Color(1f,1f,1f), new Color(.666f,.843f,.843f), new Color(1f,.843f,0f), .3f, 0);
	public static EElement FIRE = new EElement(AIR, "FIRE", 	new Color(1f,.25f,0f), new Color(1f,.75f,.1f), new Color(1f,.6f,.078f), .1f, .6f);
	public static EElement WATER = new EElement(FIRE,"WATER", 	new Color(0f,.274f,.9f), new Color(.04f,.843f,.568f), new Color(.588f,1f,1f), .4f, .1f);
	public static EElement SPIRIT = new EElement(WATER,"SPIRIT", 	new Color(.784f,.627f,1f), new Color(.725f,.510f,1f), new Color(.9f,.5f,1f), .3f, .15f);

	private EElement(EElement a, string name, Color c1, Color c2, Color c3, float g1, float g2) {
		goodAgainst = new List<EElement>();
		goodAgainst.Add(a);
		elemName = name;
		primary = c1;
		secondary = c2;
		tertiary = c3;
		glowRatio = g1;
		glowBoost = g2;
	}
	
	public override string ToString () {
		return string.Format(elemName);
	}
}

The colors (etc.) are used later by a custom shader and the good-against is for damage/resist types.

 
Flag Post

Topic: Game Programming / Troubles with Array lenght!

Fair ’nuff, but you can still create enums for this sort of thing.

I haven’t messed with enums in AS3 (and you kind of have to fake it) but it is a type of object that compiles very cleanly without (much) overhead and in most languages, causes the values to be inlined, reducing lookup.

http://www.kirupa.com/forum/showthread.php?297579-How-to-do-enums-in-AS3

 
Flag Post

Topic: Game Programming / Troubles with Array lenght!

public static class Armor {
    private static var item1:String = "leather";
    private static var item2:String = "leatherHard";
    public static function getLabel(upgrade:int) {
        switch(upgrade) {
            case 1:
                return item1;
                break;
            case 2:
                return item2;
                break;
        }
    }
}

etc. There are probably better ways still (cough, enums, making the armor movieclip itself a class, etc.), but this is still better than using dynamic objects.

Such as not-using-frame-labels.
gotoAndStop(theUpgradeLevel) is perfectly sufficient. theUpgradeLevel is an integer, no? Frame numbers are also integers.

 
Flag Post

Topic: Game Programming / Troubles with Array lenght!

That’s still a dynamic object, you need to create a new .as file:

public class Armor {
    public var item1:String = "leather";
    public var item2:String = "leatherHard";
}
 
Flag Post

Topic: Game Programming / New programmer considering Unity3D

Originally posted by zapleaf:

Ignore posts like this. I was told this for ever about making a Online Multi-Player type of RPG. One day I told myself I was going to do it and so I did, and the end result was challenging but I had so much fun.

http://yourgameideaistoobig.com/

 
Flag Post

Topic: Game Programming / New programmer considering Unity3D

Then it ceases to be an RPG and becomes an arena combat game.

You took the RP out of RPG. The whole point of a role playing game is to assume the role of a character.

 
Flag Post

Topic: Game Programming / New programmer considering Unity3D

Originally posted by Bulbopon:

a simple RPG.

Doesn’t exist. RPGs are inherently not simple. You need a world, a story, a combat system, character stats, levels, items, inventory management, dialog sequences, probably some cutscenes, area transition animations, monsters, and a whole lot of other stuff.

 
Flag Post

Topic: Game Programming / Battle pirates MMO

Originally posted by Tt_games:

How would it be possible to bring “Battle pirates” the MMO to kongregate?

1) Contact the developer
2) Wait

 
Flag Post

Topic: Game Programming / Kongregate not respecting the width/height I entered

Originally posted by player_03:

Is it possible that you compiled the game with those other dimensions?

Unity webplayer files don’t have a size. The whole “I compiled it with X size” just changes the embed dimensions in the HTML file it generates.

 
Flag Post

Topic: Game Programming / Load .png without premultiplying alpha channel?

Not in Flash AFAIK

 
Flag Post

Topic: Game Programming / In-game Events: Storing the target as a variable or passing it each time

Simply:

You need a finite state machine. Each “GameEvent” is one state of that state machine.

 
Flag Post

Topic: Game Programming / In-game Events: Storing the target as a variable or passing it each time

Events happen to objects. If, for example, the character gets stunned, then the character should have a component attached to it that says its stunned. The event is merely the piece of code that attaches that “stunned” component to the character. Another event (duration expired) removes it.

http://www.kongregate.com/forums/4-game-programming/topics/338362-deeper-topic-part-3-events-to-the-rescue

For something that happens at a game level, the event will fire, the main script will hear it and do something. Probably switching states and doing the random encounter code/display, etc.

Events themselves shouldn’t be considered objects (although there will be a codewise object that represent the event data, but it should be treated as a temporary object that as soon as the event has finished execution1 is destroyed).

1 by which I mean that it should last less than 1 frame. It may have continuing effects, but they are not the event itself, but they are not handled by the event object.

 
Flag Post

Topic: Game Programming / Some Advice Against Unity

Originally posted by Darvious:

Think about it: The net has been popular for roughly 15 years now. Assuming that the average child wanted a computer / laptop between the ages of 10 and 12, what sort of computers do you think that these children received from their parents? Hand me downs.

This is hilariously untrue.

The kinds of families that this statement alludes to are the kinds of families that wouldn’t have HAD a computer 15 years ago. More likely, kids these days are getting on at school (where computers are of an indeterminate age, but generally less than 8 years old1). At home they’re likely to either have a single family machine that is strictly regulated (“You only get X amount of computer time a week, after homework”) or a mobile device (iPad, etc.) that belongs to them, or no access at all.

I had to work for and save up my money to buy my own computer as a kid. We had two computers at the time, an old 486 that was good enough for internet browsing at the time (we still have it in the basement, I have no idea why), and a newer Compaq presario—midrange home computer for the time.

I’ve replaced my hardware twice since then, my parents have also replaced their machine at least twice (the Compaq died and then down-graded to a free machine they got somewhere for a while (it was enough for email) before getting a new one—I think the one they have now is even newer than that, but it’s a bit fuzzy).

So really, no. “Kids these days” are not going to be running on hand-me-down hardware. It would be neigh unusable unless they and the machine’s previous owners actually knew how to keep it free of malicious software and maintain it. Which is absurdly unlikely, as it would imply a greater knowledge of computers than their low-income status would allow for (on account of not being around the technology 24/7).

1 I worked as an IT desktech at a school. They had some old computers, but they were kept in good shape by doing a complete wipe, reformat, reinstall every 6 months. It was hardware that was simply aging, but if something actually failed, the machine was replaced. New machines were bought in bulk once a year, generally going to faculty. Those machines were then wiped and replaced even older machines on down the chain. So the oldest of the oldest were only about 12 years old (there was one computer lab with these ancient relics, everything else was newer).

 
Flag Post

Topic: Game Programming / This piece of code causes memory leak. Unsure, why.[as3]

AFAICT, TLF textfields are awful. I have not found a good reason to use them over classic textfields yet.

 
Flag Post

Topic: Game Programming / This piece of code causes memory leak. Unsure, why.[as3]

Yes, there is a reason – me going crazy because of memory leak and discarding all possible sources. I never set variables to null like this usually.

Creating new pbullet()s every frame IS your memory leak.

By the way:

public class Global extends EventDispatcher {
//blah blah blah
	var curw = Global.curturner.curweapon;

You don’t need to do this. var curw = curturner.curweapon works just as well. And there’s a larger problem of increasing RAM usage by 1 pointer in order to save a single dot-lookup not really being worth it.

Ditto goes for all other Global.[whatever] because the current class IS the Global class. You can actually find-replace “Global.” with an empty string and it’ll compile just fine (same goes for “this.” although the compiler strips that out automagically, as it’s there for the programmer).

There’s also no need to set local variables to null at the end of the function, function returns automagically clean up their local variables. Setting null actually causes an extra instruction on the CPU.

 
Flag Post

Topic: Game Programming / This piece of code causes memory leak. Unsure, why.[as3]

I’m not sure if I’m reading your code right, but are you really recreating every bullet every frame (or recreating your HUD every frame)? If so, then the lag is most likely coming from the GC itself since it’s a very VERY slow process.

Pretty much that. You’re rebuilding your HUD from scratch every frame rather than just changing what needs to be changed, so you’re garbage collecting a TON of stuff every frame.

 
Flag Post

Topic: Game Programming / Time spent on games

I spend way to much time and never finish anything :p

 
Flag Post

Topic: Game Programming / Unity

That’s why I said Shader Forge. Shader Forge was built to be for artists and remove all the “magic” of having to write shaders by hand. I put that image up as an example of what I managed to accomplish in only a couple of hours utilizing only some texture files that came with Shader Forge and a ridged perlin noise map off Google.

I’ve worked in chader code a couple of times and every bloody time it’s been a mess of “so if I declare the variable as a myVert and give that custom class a normals property, it comes into my function like magic?” *compile* “….apparently so.”

Long story short: the default shaders will look boring and flat no matter what you do. Get some good ones. There’s a bunch of free packs out there, but don’t expect them to have everything.

 
Flag Post

Topic: Game Programming / Unity

I have this thread on optimizing rendering in Unity. A couple of them are pro-only, but its still a good reference.

I also suggest picking up Shader Forge (video of the dev talking about why he made it) when you can afford it. It only took me a couple of hours (across two days) to do this:

Until then, go snag as many free shader packages as you can, the more non-default shaders you use the less people will recognize that you’ve used unity. I picked up Shader Forge when it was half-off and am very glad I did so.

 
Flag Post

Topic: Game Programming / The future of flash

/me reads title
/me sighs, another one of these threads

Flash is not dead, mobile gaming is on the rise, and while other development options are increasingly powerful and cross platform, Flash is still very good for web deployment. Having those skills on your resume will look good. If I’m doing something 2D, Flash is where I’d start unless the needs of the project will not support Flash.