Recent posts by trashantboy on Kongregate

Flag Post

Topic: AdVenture Capitalist / Progress stops when offline

Adding a further confirmation: idle progression has broken in this upgrade. It seems that AI are being calculated properly, but cash is not. So you come back with lots of AI ready to reinvest, but no cash to buy upgrades if you don’t want to reset yet

 
Flag Post

Topic: Game Programming / Stage retaining an original copy of moved sprite

Found the answer, thanks to someone from SO. I wasn’t removing the event listener in init, so it was firing during both the capture and the bubble phase and creating two floor objects, only one of which was called with the variable. I don’t think I would have noticed that; I spent hours last night working on it. It’s always the little things…

 
Flag Post

Topic: Game Programming / Stage retaining an original copy of moved sprite

I have never seen this happen before. I have some very simple code to display a Sprite and move it around. I first add it to the stage with this code:

public var floor:Floor;
public var char:Character;

public function Game()
{
addEventListener(Event.ADDED_TO_STAGE, init);
}

private function init(e:Event):void{
floor = new Floor();
addChild(floor);

char = new Character();
addChild(char);
char.x = stage.stageWidth – char.width;

var item:Sprite = new Sprite();
item.graphics.beginFill(0×666600);
item.graphics.drawRect(400, 400, 50, 50);
item.addEventListener(MouseEvent.CLICK, moveEast);
addChild(item);
}

That last bit with the graphics is just for testing; basically, I want a button that I can press and have it shift everything by 50 pixels. This is the moveEast function:

public function moveEast(e:Event):void {
floor.x += 50;
}

As you can see, it is very straightforward. In theory, I should add my Floor object, then move it to the right 50 pixels whenever I push the button. However, in practice, what happens is that is both shifts and doesn’t shift. Specifically, it does shift; I can move it all the way across the stage and have the complete object move. However, it ALSO retains a copy of the object at the original position. I am confident that I have not accidentally added another child somewhere. If I remove the single addChild(floor) line from my code, then nothing shows up. Any ideas on why it might be doing this?

 
Flag Post

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

Haven’t used that structure before. Any easy-to-understand links you can pass along?

 
Flag Post

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

I may be using ambiguous terminology. When I say event, I really meant event on a gaming level, not an event on a coding level. I don’t want this running with listeners, and it will not ALWAYS be the character interacting with the event.

Each of these events COULD be coded as separate functions in my main script. In other words, I could have a function like encounterEnemy, that could be called from the main script and would run through an encounter. This might do things besides affect the character. For example, they might cause sounds to play, or change the layout of the map, or other things. However, I want to separate them out into individual classes, with the GameEvent as a superclass and all the individual events as child classes rather than creating blocks of code in my main script.

 
Flag Post

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

Sorry, I’ll try to be more clear. I’m still in the design phase, so everything is a little nebulous in my head.

I have a character that is going to be exploring a location, tile by tile. On occasion, GameEvents will occur. These are events that will impact the game in some way; in fact, they are the core of the game. They include plot events, random encounters, and anything else that happens besides exploring a new tile. These events will interact with a Character object, which will primarily be the player’s character although if time permits may also include NPC’s or monsters. Some events will be one-shot things, while others might have effects that take place over several turns.

As I said, I’m still in the design phase, and I am trying to determine if each event should have it’s own reference to the target Character, or if the target should be passed anytime the event triggers.

 
Flag Post

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

I’m working on a project that involves a series of GameEvents that will interact with a Character in one way or another. The GameEvents will be objects, since some of them will be persistent over several turns. However, I am trying to decide the best way to structure the target.

The two ways that I’m considering are:
A) Pass the character as part of the constructor and storing it in a variable which can then be accessed from anywhere within the class.

B) Pass nothing to the constructor, but pass the character as an argument to any function that would need to use it.

I don’t know enough of about the inner working of AS3 to determine which would be better. In Java, for example, the instance variable in A would just be a reference to the object in memory and would hardly impact performance whatsoever. To those who understand AS3 a little better: what are the pros and cons of these two methods? Or is there a third method that would work even better?

Also, I’m programming raw code in FlashDevelop. Not using movie clips or a timeline, just in case that impacts anything.

 
Flag Post

Topic: Rise of Champions / Bugs

Veteran Task 3 bug is still not completely fixed. The task is “Defeat Yog-Sotheth”, but it claims that the task is completed after defeating Golem. However, if you try to claim it at that point, it gets locked into “checking reward” forcing you to restart. The claim button should not trigger until Tog-Sotheth is defeated.

 
Flag Post

Topic: Game Programming / 2014 One Game a Month

I missed April (finals month is super busy for full-time tutors :D) but here is my game for May:

http://www.kongregate.com/games/trashantboy/platformerbeta

 
Flag Post

Topic: Game Programming / Selecting a target with a mouseEvent

The way I am currently doing this, which appears to be right based on what I can find online, is to have the parent actually call the attack. When the attacking character is chosen, rather than adding the event listeners to the chosen character, I add them to the parent. I also set a variable in the parent to reference the attacker (parent.attacker = this);

Then, when the listener fires with a mouse click, the parent calls attacker.launchAttack(e.target) before resetting attacker to null. This will allow the chosen character to fire at the chosen target. If anyone has a better way of doing this, let me know.

Of course, this still has its problems. Currently, the chosen attacker is hitting himself because the event listener to launch the attack is being added (and fired) before the event for selecting finalizes. However, since I know why this is happening I should be able to get around it.

 
Flag Post

Topic: Game Programming / Selecting a target with a mouseEvent

Because the attacking character can be any of several members of the team. The player will select that as well

 
Flag Post

Topic: Game Programming / Selecting a target with a mouseEvent

I’m working on a larger project, and I am running into a simple problem that is giving me far more trouble than it should. I want to be able to choose which character to use an attack on by clicking on the appropriate icon. There will be a large number of possible attacks/character types, so what I would like to do is be able to call the attack function like so:

typedAttack(Character)

where “typedAttack” is one of several different attack function within the character doing the attack, and Character is the target of the attack (which can be any Character, as Character would be a parent class).

However, I cannot figure out how to get the attacking character to listen to an event on another character. I would think that I should be able to use a MouseEventListener.Click and just make sure the target (not currentTarget) is a character which I can pass to the attack function, but since the event only captures and bubbles up to the stage and back in a line of direct ancestors, the attacking character can’t hear the event. I’ve been experimenting for a bit, and I’ve managed to make both attacker and attackee attack simultaneously, or to have the attacker only be able to attack himself.

It’s probably a simple solution that’s just staring at me, but how can I get this to work?

 
Flag Post

Topic: Game Programming / 2014 One Game a Month

March’s game. It’s a quick one. I’ve been working on a bigger game, but wanted to get one in for the month so I wrote it in 8 hours while driving across the country. (I was a passenger, obviously)

http://www.kongregate.com/games/trashantboy/mastermind

 
Flag Post

Topic: Game Programming / Using an icon set

I want to use some of the icons found here in my March game of the month game, but I’m not entirely certain how to go about doing so. I could probably just trim down the full set to get the one I want since modifications are allowed under the license, but if I wanted to use a sprite set for animation, for example, that clearly wouldn’t work.

Last I looked, I thought I understood the theory. You put the set on the field, then mask it with something else so that only the part you want showing shows up. If you want to animate something, you then move the back one so that different parts show in sequence.

Is that still considered best practice, or is there another way to do it in actionscript? If it is, can someone post some example code for the mask, because I’m not actually sure how to implement that so that it doesn’t interfere with whatever else is on screen (backgrounds, etc.). If it’s not, could someone point me in the right direction?

 
Flag Post

Topic: Game Programming / 2014 One Game a Month

I forgot to post this, but it was up by February: www.kongregate.com/games/trashantboy/evil-hangman

 
Flag Post

Topic: Game Design / Good tutorials for artwork?

So… I’ve never made any of my own art for a game. So far, I have used basic shapes created programatically to represent game elements for something like a concept test, or I have gotten open-source artwork that has a license I can use. I’m thinking about trying to do a little of my own artwork for a simple game I’m working on, but have NO idea how to go about it. Where can I find some good tutorials for creating digital art? What are some good software solutions for drawing game art? Where do I go to learn from the ground up?

 
Flag Post

Topic: Game Programming / Pros and Cons of subclassing

@Archiepl1: That’s basically what I did with the concept test I threw together to post here last month. I just made them all Sprites, not GameComponents, but the way I used them was basically the same. Is GameComponent an interface that you put together, or just the way you think about it, or what? I don’t see it in the trunk api, so that’s why I’m asking. Is there additional functionality above and beyond that available to a Sprite?

@Vesper: Hello! Thanks for the answer over there. I think between the two answers from you and Archie, I know how I’m going to make this work.

 
Flag Post

Topic: Game Programming / 2014 One Game a Month

I didn’t even know what 1GAM was until today. I’ll whip up a profile soon and link it for the OP. And since it doesn’t seem to have gotten including, this is my entry for January.

http://www.kongregate.com/games/trashantboy/concept-test-toy-soldier

 
Flag Post

Topic: Game Programming / GiTD #37 - Congrats moocowsgomoo!

So… this is probably an obvious question, but what does GiTD stand for?

Edit: Nvm, just saw the sticky.

 
Flag Post

Topic: Game Programming / Pros and Cons of subclassing

I am working on a version of hangman with some interesting programming twists. I don’t need to go into detail of what they are as the logic for the game is already finished. I can run an entire game by hard-coding variables for the user input (such as guess selection). I am now in the process of replacing all those bits that require user interaction with the trappings of an actual game like buttons, images, sounds, etc.

I am trying to figure out whether it is better to have all of this stuff be part of my main class, or whether I should create another class to handle it all. For example, I want my players to be able to click on an on-screen keyboard to make their guess, with each button firing a separate event listener call to the makeGuess function. Would it be better to create the buttons as direct children of my main game class, or should I create a subclass (called Keyboard, for example) that creates the keyboard section of the board with the appropriate events, then add the keyboard class as a child to the main rather than all the pieces? What are the pros and cons of each of these choices?

For the record, I’m programming using FlashDevelop, so nothing like a timeline for me.

 
Flag Post

Topic: Game Programming / Loading data from File objects

Final update: I didn’t even have to loop through the ByteArray. Final code to include a text file consisting of 60000+ words into my swf looks like this:

var test:String = new Assets.Dictionary().toString();
var words:Array = test.split(“\n”);

This gives me easy and quick access to the full list of words. Storing the entire list of 60000 words and accessing one of them in a trace took less than a second. The compressed .swf file is only 200kb at this point. Granted, that will increase when it’s more than just storing an array of strings, but this ended up being MUCH easier than I was making it.

Thank you both for all the help. It was what you said that got me pointed in the right direction. I really appreciate it.

 
Flag Post

Topic: Game Programming / Loading data from File objects

Actually, it looks like I don’t even have to bother. According to this page it’s possible to embed the entire .txt file, which I can then parse out based on newline byte characters. Even with 60,000 words, the .txt file is only .5mb, which means it shouldn’t take up too much room in my final .swf, even after parsing and storing as strings. I hadn’t realized that embedded it as a ByteArray which can be accessed directly. No need for File objects like you would in Java, or even xml (65mb for the same list)

 
Flag Post

Topic: Game Programming / Loading data from File objects

Thanks for the answer, both of you. Just to be clear, I’m going to need to convert the text document into xml (or JSON), then embed the file as xml. Then I can use the file directly, because actionScript has an xml object type that I can use to access it directly. Is that correct?

If so, is there an easy way to convert a text file (strings separated by newline characters) into an xml file?
Edit: It looks like Microsoft Word has a way to convert .txt files directly into xml, so that should work nicely.

 
Flag Post

Topic: Game Programming / Loading data from File objects

Honestly, I just thought that I had to use it to access a file. That’s what we have to do in Java, and I’m developing this program concurrently in both languages for practice.

How do I access the information from a text file if it’s embedded? With images, I have to create a BitMap variable and assign the image to it. I thought I would have to do something similar with the text file, and I just assumed it would have to be a File object. Can I just assign it to a String, or a String array, or something?

Edit: After a bit more research, it looks like I can use a URLLoader? How does that work with an embedded file?

 
Flag Post

Topic: Game Programming / Loading data from File objects

Problem #2: I can’t import flash.filesystem so that I can get access to the File object. I’m using actionscript 3 in FlashDevelop. I have no idea why I can’t import this particular object.

So, is there a way to either import this even though it isn’t showing up in my library? Or, barring that, is there a way to access the information from a text document without using a File?