Be a Supporter!
Response to: Adding to text with variables Posted December 24th, 2013 in Game Development

From the looks of this you're using ActionScript 2.0, but correct me if i'm wrong.
From what I can see, the problem is that you are never actually updating the text. In the code you posted, you set the text to display what you want in the line

moneyamount.text = "Money: " + Money;

which from what I can see works just fine. However, this line only sets the text to display "Money: " + the value of Money at that point in time, so it won't update the text whenever Money changes, such as in your button handler.

To fix this I guess you could just put the text update line in the handler, like this

on(release){
Money += 5;
moneyamount.text = "Money: " + Money;
}

That way, whenever you press the button, Money will increase and it will update the text to reflect the new value.

It's been a long time since I worked with AS2, but I think there's an easy way to link a variable to text field so that it updates automatically, but I've forgotten how. In any case, this should work.

Response to: AS3 "a" key press problems Posted August 24th, 2011 in Game Development

Yeah I'm kind of stupid, after you said keyboard shortcuts I added a rectangle which changed colour when you pressed a key, and then ran that on the flash player, it always worked, just the shortcut got in the way somehow.
Lolz

Anyways, thank you for the replies and for helping me fix it

AS3 "a" key press problems Posted August 24th, 2011 in Game Development

Hi I'm trying to make a system where i can just loop through to check all the keys instead of coding in each one manually, and everything seems to work but the "a" key. I can press it once, and it will register, but any subsequent presses have no effect at all. It doesn't matter when I press it, and all the other keys work fine, it's just the "a" key will only register once. If anyone could just test this on another computer to check if my keyboard is broken or spot any bugs in the code I would greatly appreciate it.

import flash.events.KeyboardEvent;

var inputKeys:Array = new Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
"k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
"u", "v", "w", "x", "y", "z");

function inputKeyDown(event:KeyboardEvent):void
{
	var keyI:int = 0;

	for (var i:int = 0; i < 26; i ++)
	{
		keyI = 65 + i;
		if (event.keyCode == keyI)
		{
			trace(inputKeys[i]);
		}
	}
}

stage.addEventListener(KeyboardEvent.KEY_DOWN, inputKeyDown);

function inputKeyUp(event:KeyboardEvent):void
{
	event.keyCode = 0;
	trace("NO KEY");
}

stage.addEventListener(KeyboardEvent.KEY_UP, inputKeyUp);

For right now the alphabet array is just there to print out stuff, it will later be a boolean array that I can check in the main code to do things like moving or whatever. The intputKeyUp function doesn't actually do anything, I was just checking to see if resetting the keyCode after every key press would solve the problem, but it didn't.

Here's some sample output

s
NO KEY
d
NO KEY
f
NO KEY
d
NO KEY
s
NO KEY
a
NO KEY
//Me furiously hitting the "a" key again, nothing happening
d
NO KEY

Thanks in advance

Response to: Letting you know Posted March 31st, 2011 in General

FUCKFUCKFUCKFUCKFUCK

Response to: Letting you know Posted March 31st, 2011 in General

I believe you

Response to: What song are you listening to? Posted February 10th, 2011 in General

Black Sheep - Metric

Response to: ITT: Elfer fix yo' life Posted January 26th, 2011 in General

At 1/26/11 04:11 PM, Lagerkapo wrote: Then I tried doing a bunch of drugs and all I got was high.

Rinse and repeat

Response to: Creepy shit in your town? Posted January 26th, 2011 in General

I live in a totally cool and normal english village, nothing bad here.

Response to: ITT: Elfer fix yo' life Posted January 26th, 2011 in General

Mornin, I feel like I should be sad and/or depressed, but I'm not. Whats up with that.

Response to: Worst pick-up lines Posted December 20th, 2010 in General

Also, a line stole from a song by The Cataracs,
"Your daddy must have been a drug dealer, cause you dope"

Response to: Worst pick-up lines Posted December 20th, 2010 in General

"I've had sex before and I know what I'm doing."

Response to: C++ fstream newbie problems Posted December 20th, 2010 in Programming

Well, if no one knows how to fix this, then is there a workaround for opening/manipulating files, cus opening/manipulating files seems essential for doing nearly anything complicated.

Response to: C++ fstream newbie problems Posted December 19th, 2010 in Programming

Brilliant suggestion, and it probably fixed another problem, but it still doesn't find/create the file. I've also noticed that the open() and close() commands apparently don't exist.

Response to: C++ fstream newbie problems Posted December 19th, 2010 in Programming

Well it's not really that is_open() doesn't work, it's that the program can never find the file specified, and doesn't seem to automatically create one otherwise.

Could it be a problem with what I'm #Including, as I noticed before there seems to be separate libraries for things, such as there being two math libraries, cmath and math.h, and maybe I'm using the wrong fstream or string one?

C++ fstream newbie problems Posted December 18th, 2010 in Programming

Just started to learn C++ a couple days ago, the basics weren't too difficult as I'm familiar with languages based on/influenced by it, i.e. Java and ActionScript, but I've run into problems with some File I/O practice programming.

I'm using CodeBlocks for Mac OS, and I'm writing a console application. Since just opening a file seemed a bit trivial, I wanted to try and see if I could open/create a file with the name the user entered and do stuff such as add user entered text into the file. Doesn't seem to hard, but it seems that my program can never locate the text file I made for it to open, called "example.txt". The problem can't be with file location or something because I made a copy of the file and put it in every folder in the project, so every level of the folder containing the project has a copy of the file.

After this happened, I tried just opening a file and printing out what it contained or adding stuff to it. Neither ever found the file or modified it in any way.

I don't know what to do, and I've checked google and whatnot, and got nothing. Any help would be greatly appreciated.

This is my code so far:

#include <iostream>
#include <fstream>
#include <cstring>

using namespace std;

int main()
{
    char fileName[11];
    cout << "Please enter the name of the fle you wish to open:";
    cin.getline(fileName, strlen(fileName), '\n');

    ifstream fileImport (fileName);

    if(fileImport.is_open() == true)
    {
        char inputString[50];
        fileImport >> inputString;
        cout << "The file currently reads:\n";
        cout << inputString;
        cin.ignore();

        ofstream fileOutput (fileName, ios::trunc);
        char newOutput[50];
        cout << "Enter the new text for this file:\n";
        cin.getline(newOutput, 50, '\n');
        fileOutput << newOutput;
        cout << "The file now reads:\n";
        cout << newOutput << "\n";
        cin.ignore();
    }
    else
    {
        cout << "The file could not be read.\nExiting program on keystroke.";
        cin.ignore();
    }
}
Response to: Adding a listener to an array? Posted October 11th, 2010 in Game Development

Not efficient enough lol
Kidding, but I was curious if it was possible anyways. I have it working now, but thanks for the reponses

Response to: Adding a listener to an array? Posted October 11th, 2010 in Game Development

The point was that I need it to be applied to all the objects in the array. For some reason, you made me think of a very roundabout way of doing this, by making another function with a loop in it which cycles through the array and adds the listener, ect, but I was wondering if there was a more simple and direct way of doing it.

Adding a listener to an array? Posted October 11th, 2010 in Game Development

How do you do it? I know you can add an Event Listener to a specific object like so

objectName.addEventListener(Event.ENTER_FRAME, function);

But if I try to do it for an array like so

var sampleArray:Array = new Array;
sampleArray.push(objectName);

sampleArray.addEventListener(Event.ENTER_FRAME, function);

I get an error

TypeError: Error #1006: addEventListener is not a function.
	at Selection_fla::MainTimeline/frame1()

Thanks in advance for any help you guys can provide

Response to: What language does a deaf person... Posted September 4th, 2010 in General

Pure conceptual thinking, only meaning and idea with no language attached.

But maybe some pictures.

Response to: Stroopwafels Posted September 4th, 2010 in General

OMG YES
BEST THINGS ON THE PLANET

Response to: I want this. Posted September 4th, 2010 in General

I give every single idea posted in this thread my full support

Response to: Ground Collision Problem Posted August 27th, 2010 in Game Development

So no one can help?

Response to: Ground Collision Problem Posted August 26th, 2010 in Game Development

Ba - dum - bump

Response to: Ground Collision Problem Posted August 26th, 2010 in Game Development

No effect with taking those two lines out, and yeah, the gravity = gravity was just keep it the same, even though it would probably do the same without that line.

Response to: Ground Collision Problem Posted August 25th, 2010 in Game Development

Bump for great justice

Ground Collision Problem Posted August 25th, 2010 in Game Development

I am running a little test, which includes, among other things, a ground collision and jumping feature. As of now I have a character that can run left and right while playing an animation, as well as jump to different platforms in different levels and so on. To do this i put all my ground MC's into an array and cycle the collision code through them in a for loop.

My problem is that for every new platform in the array, the character sinks lower and lower through them. The last MC in the array he rests perfectly on, while each previous one he sinks progressively lower, no matter their coordinates on-screen.

I'm very perplexed as to why this is happening, especially since the only working one is the last one in the array, however I'm sure it's just some kind of logic error I just can't see. I would greatly appreciate any help that anyone could provide.

Here is the code as of right now -

var i:Number;

var up:Boolean = false;
var down:Boolean = false;
var right:Boolean = false;
var left:Boolean = false;
var aKey:Boolean = false;
var sKey:Boolean = false;
var dKey:Boolean = false;

var xSpeed:Number = 0;
var xAcl:Number = 8;
var xLimit:Number = 12;
var xDecay:Number = 0.6;

var gravity:Number = 15;
var gravityMaximum:Number = 15;
var groundCollision:Boolean = false;
var groundArray:Array = new Array(ground, ground2, ground3);

function keyDowns(event:KeyboardEvent) {
	if (event.keyCode == 38) {
		up = true;
	}
	if (event.keyCode == 40) {
		down = true;
	}
	if (event.keyCode == 39) {
		right = true;
	}
	if (event.keyCode == 37) {
		left = true;
	}
	if (event.keyCode == 65) {
		aKey = true;
	}
	if (event.keyCode == 83) {
		sKey = true;
	}
	if (event.keyCode == 68) {
		dKey = true;
	}
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDowns);

function keyUps(event:KeyboardEvent) {
	if (event.keyCode == 38) {
		event.keyCode = 0;
		up = false;
	}
	if (event.keyCode == 40) {
		event.keyCode = 0;
		down = false;
	}
	if (event.keyCode == 39) {
		event.keyCode = 0;
		right = false;
	}
	if (event.keyCode == 37) {
		event.keyCode = 0;
		left = false;
	}
	if (event.keyCode == 65) {
		event.keyCode = 0;
		aKey = false;
	}
	if (event.keyCode == 83) {
		event.keyCode = 0;
		sKey = false;
	}
	if (event.keyCode == 68) {
		event.keyCode = 0;
		dKey = false;
	}
}
stage.addEventListener(KeyboardEvent.KEY_UP, keyUps);

function action(Event) {
	for (i = 0; i < groundArray.length; i++) {
		if (gravity <= gravityMaximum - 0.1) {
		up = false;
		}
		if (up == true && groundCollision == true) {
		gravity *= -1;
		} else if (up == false) {
		gravity = gravity;
		}
		gravity += 1;
		player.y += gravity;
		groundCollision = false;
		if (player.y > groundArray[i].y 
		&& player.y < groundArray[i].y + player.height + groundArray[i].height 
		&& player.x <= groundArray[i].x + (groundArray[i].width/2) + (player.width/2) 
		&& player.x >= groundArray[i].x - (groundArray[i].width/2) - (player.width/2)) {
			player.y = groundArray[i].y;
			gravity = gravityMaximum;
			groundCollision = true;
		}
	}
	/*if (gravity <= gravityMaximum - 0.1) {
		up = false;
	}
	if (up == true && groundCollision == true) {
		gravity *= -1;
	} else if (up == false) {
		gravity = gravity;
	}
	gravity += 1;
	player.y += gravity;
	groundCollision = false;*/
	if (right == true && left == false && xSpeed < 0) {
		player.scaleX = -1.0;
		player.gotoAndPlay(21);
		xSpeed += xAcl;
	} else if (right == true && left == false) {
		if (player.currentFrame == 1 || player.currentFrame >= 20) {
			player.scaleX = 1.0;
			player.gotoAndPlay(2);
			xSpeed += xAcl;
		}
	} else if (left == true && right == false && xSpeed > 0) {
		player.scaleX = 1.0;
		player.gotoAndPlay(21);
		xSpeed -= xAcl;
	} else if (left == true && right == false) {
		if (player.currentFrame == 1 || player.currentFrame >= 20) {
			player.scaleX = -1.0;
			player.gotoAndPlay(2);
			xSpeed -= xAcl;
		}
	} else if (right == false && left == false) {
		player.gotoAndPlay(1);
		xSpeed *= xDecay;
	}
	if (xSpeed > xLimit) {
		xSpeed = xLimit;
	} else if (xSpeed < -xLimit) {
		xSpeed = -xLimit;
	}
	player.x += xSpeed;
}
stage.addEventListener(Event.ENTER_FRAME, action);

Note: The large section with the multiple and's that detects if the player is touching the MC are indented mainly for easier reading, and the same problem occurs weather they are indented or not.
Also, the commented part outside of the for loop is where I tried to put the gravity code outside the loop, to see if it was causing the problem. Instead, My character can jump 3 times higher, and he sinks through all platforms to the same depth.

Response to: As4? Posted May 15th, 2010 in Game Development

I seriously doubt there will be an AS4 in the near future, and if if there is an AS3.1, it wont be too different to current AS3

Response to: Medal Get! Posted May 15th, 2010 in Game Development

mac ss = cmd + shift + 4

Response to: Question on creating Art Based game Posted May 15th, 2010 in Game Development

I could be wrong, but I'm assuming that art based games are ones in which you draw the graphics in flash, and code based is where you create any graphics and effects using code.

Response to: Blounty is a mod? Posted April 13th, 2010 in General

The hell is an icon mod?