Recent posts by Arcaian on Kongregate

Flag Post

Topic: Game Programming / Collection of Questions by 2by4

You’re getting a little confused with your terms here. The coding language for flash is Actionscript, so it’s AS not AC. The most updated version is AS3, and it is roughly 10x faster than AS2. I strongly reccomend you start at this language, not AS2. The IDE you use to develop can change, the two most common IDEs are the Adobe Creative Suite (CS) and the Flash Develop IDE. Flash Develop doesn’t have the inbuilt graphics that the CS has, but it is free, and is useful for advanced coding.

Adobe’s Creative Suite is rather expensive, unless you get a student/eduction copy. However, you can get a 30 day trial – I would reccomend getting the 30 day trial for CS6.5, then try it out. Learn AS3, then once you’ve used it for 30 days, get Flash Develop and try it out – if you don’t like it, you’ll have to buy CS.

Definitely use AS3, not AS2 – http://www.kirupa.com/ isn’t bad for tutorials, or http://www.actionscript.org/ is good as well. Get started with beginner tutorials ;)

 
Flag Post

Topic: Game Programming / [AS2] Hit Detection issues with my car movement

Alright guys, thanks a bunch! That was the problem, it just took me a while to figure out how to do the whole parentToGlobal() thing, but got it now. It’s working! Thanks :D

 
Flag Post

Topic: Game Programming / [AS2] Hit Detection issues with my car movement

Ah, right. Read your post incorrectly. Yeah, I know it can’t be that precise, but for what I’m doing, it’s perfectly fine :D

 
Flag Post

Topic: Game Programming / [AS2] Hit Detection issues with my car movement

I’ll more than likely be changing to AS3 after this project is done. Most likely I’ll be using this game as a base, and re-coding it in AS3. But the AS2 hit detection isn’t terrible for what I’m doing, so I will most likely release it in AS2. Thanks for the help guys – can’t try out that link now, no flash on this comp.

 
Flag Post

Topic: Game Programming / [AS2] Hit Detection issues with my car movement

Sorry about that code formatting – I didn’t know how to put in the pre tags, and forgot to check the stickies. Posting a thread at 12am is probably not a good idea, now that I’m thinking about it. Sorry about that. Trying to answer the questions now.

@dragon_of celts
What I mean is that when you try and do anything that requires the object’s x andy, it doesn’t work properly. As an example, I made it so that when I press E, it traces the _x and _y locations of both the atm (a small object) and the car. Then I drove the car over the atm, pressed E, and the car’s _x and _y were something like ~500 away from the atm, although I was over it graphically. It’s confused the hell out of me.

What I meant by shapeflag is, I try and hitTest like this:

if(_root.background1.atm.hitTest(_root.background1.car._x, _root.background1.car._y, true)){
//blah
}

Then it doesn’t work. This is the same way I hitTest for my character’s collision with the same buildings, and it works correctly. However, if I do this:

if(_root.background1.atm.hitTest(_root.background1.car)){
//blah
}

It works fine. When I tested further, the car wasn’t reporting it’s _x and _y values as what they should be, and such the hitTesting was off. And thanks for that thread, reading it now and it looks like it could well be the problem – funny, as thats what I thought it was at first, but discounted it later on. I’ll do some testing with that soon, hopefully today :)

And I am not multiplying by one really, I did do that for a reason. The reason it’s one is because it’s a value I can change to allow for bettter or worse turning, and I felt that 1 suited the pace of my game. The reason I multiply it with speed rather than simply add speed, is because if the speed is very low (as in below 5 or above -2.5, as shown in the code), then it’s going to get a rather small amount of rotation turn, which is what I wanted. On top of this, if the speed hits 0, then you can’t turn at all. You can get this by adding speed directly, but like this I could change that 1 to a 5 and the turning angle would change significantly – say I wanted to create a high-speed GTA2-style game, I imagine I could use similar code. Hopefully at least – but you are definitely right in that I should merge those two if statements together, don’t know why I did it like that. I’ve got the tutorial to do, and this car hitTesting. Then, hopefully, I can work on cleaning up the code and some optimizations before a release shortly.

As to the Math.abs call, I knew they were inefficient, but I didn’t think they are 25 times slower. I’ve not had trouble with lag so far, but if I find I need to make some optimizations, I’ll change that. Thankfully, it’s one of the few Math calls I’ve made in the code. As to the speed, yeah, you’re right. The Maths.abs doesn’t make that much sense there anyway, just plain speed is what I wanted. I wrote some of this a little late, but the plan was to get the hitTesting working then look at the code. Probably should’ve done that first :)

And thanks for the suggestions on the speed, I’ll definitely look into it if I need speed – at the moment, I’m fine with it at the moment, but if people wants some optimizations, then I’l definitely do it.

 
Flag Post

Topic: Game Programming / Creating A Save File

Keep in mind that I’m pretty noob at AS2 – I’m just finishing up my first game now, a top-down game, similar to Stick RPG. I don’t need an extremely complex saving system, so not sure if this will work for you, but this is what is working for me – it really just saves variables.

function saveGame(){
myLSO = SharedObject.getLocal(“Arcaian”);

if(myLSO.data.myObj == undefined){ // No object exists trace(“Saved Game”); } else{ trace(“Overwrote Saved Game”); } myObj = {}; myObj.objArray = new Array(); myObj.objArray0 = [variable name]; // increase the 0 by one for every variable myLSO.data.myObj = myObj;

}

function loadGame(){
myLSO = SharedObject.getLocal(“Arcaian”);
if(myLSO.data.myObj == undefined){ // No object exists
trace(“No Saved Game”);
}
else{
trace(“Loaded Game”);

[variable name] = myLSO.data.myObj.objArray0; //increase the 0 by one for every variable you add }

}

I’m not sure if it’s the best code, but it works for my project ;)

 
Flag Post

Topic: Game Programming / [AS2] Hit Detection issues with my car movement

Yes, I know I should be coding in AS3. Just going to get that out of the way. I’ll make the jump soon enough, but this project needs to be finished first, then I’ll change to AS3. I might even re-write this project in AS3 as a getting-started test. Anyway, I’ve been coding it for some time, and although it is my first major game I would like to think I’ve got a fair bit better at AS2 now. I’ve written up the entire game, bar the tutorial – nothing that will be technically difficult. I wrote my own car physics, but I’m not sure if they way I’m moving the _x and _y of the car is the way that is optimal – this is the code I’m using currently:

_root.background1.car._x += Math.sin (_rotation * Math.PI / 180) * speed;
_root.background1.car._y += Math.cos (_rotation * Math.PI / 180) * -speed;

It was the one part of the car physics that I couldn’t figure out – I hadn’t even thought about converting the _rotation to work it out, so glad that I searched to find it out. My problem now, is that my car is reporting it’s _x and _y locations in correctly. At first I thought it might be because the “car” movieclip is inside the background1 movie clip, as you can see from the code. I hadn’t thought this would cause problems, but I checked it anyway – nothing causing it there. After some more … inventive solutions, nothing was working. I’m not sure why it’s not working, but I’m sure the people here in Game Programming would know. You’re all brilliant :D

If you guys need to, I can post the download link to a .fla with just my car code in it, and a sample building to hitTest. I’m not sure why it’s not working – the strange part is, if I just use the car’s instance name, it works fine. But if I try and enable the shapeFlag function (which as far as I know, requires a _x and a _y value to be submitted), it doesn’t work.

Here is the total code I use for the car:

onClipEvent (load) { 
var speed:Number = new Number (0);
}
onClipEvent(enterFrame){
	speed = speed * 0.98;
	if(Key.isDown(Key.UP) && !Key.isDown(Key.CONTROL)){
		speed += 1.2
	 }
	 if(Key.isDown(Key.DOWN)){ 
	 	speed -= 0.8;
	 }
    if (Key.isDown(Key.RIGHT)){
		if(speed < 5 && speed >= 0){
			_rotation += 1 * speed;
		} 
		if(speed < 0 && speed >= -2.5){ 
			_rotation += 1 * speed;
		}
		if(speed < -2.5){
			_rotation += 2.5;
		}
		else if(speed > 5){
			_rotation += 4.5;
		}
		speed *= 0.95;
	}
    if (Key.isDown(Key.LEFT)){
		if(speed < 5 && speed >= 0){
			_rotation -= 1 * speed;
		}
		if(speed < 0 && speed >= -2.5){ 
			_rotation -= 1 * speed;
		}
		if(speed < -2.5){
			_rotation -= 2.5;
		}
	else if(speed > 5){
		_rotation -= 4.5;
		}
		speed *= 0.95;
	}
	
	_x += Math.sin (_rotation * Math.PI / 180) * speed;
    _y += Math.cos (_rotation * Math.PI / 180) * -speed;
	
    if (Math.abs(speed) > 12.5){
		speed = 12.5;
	}
	if(speed < -5){
		speed = -5;
	}
	if (Key.isDown(Key.CONTROL)){
		speed -= speed / 5;
		if(Key.isDown(Key.RIGHT)){
			_rotation += speed / 2;
			}
		if(Key.isDown(Key.LEFT)){
			_rotation -= speed / 2;
			}
		}
	}
 
Flag Post

Topic: Game Programming / [AS2]Hit detection

Thanks, but I’m not sure how well that would work for a 2.5d game…

Thanks anyway!

 
Flag Post

Topic: Game Programming / [AS2]Hit detection

Nevermind! It was so simple, thought of a much simpler solution:
onClipEvent(enterFrame){
if(this.hitTest(root.character.x, root.character.y, true)) {
root.background1.x = (root.OldPlayer.x)
root.background1.y = (root.OldPlayer.y)
}
}

and then on movement:
if (Key.isDown(Key.RIGHT)) {
root.OldPlayer._x = this.x
_x-= movespeed;
}

It’s brilliant! :D

 
Flag Post

Topic: Game Programming / [AS2]Hit detection

I know, I know, I should stop using AS2 because it’s an archaic language that no-one uses anymore, but I want to finish this project that was started in AS2. It was finished completely except for a small new area I need to add (decided to wait for the art for that area) and the hit detection. I wasn’t 100% sure how I was going to do hit detection untill I got the art, so I only just started the hit detection today. This is what I’m using at the moment:

onClipEvent(enterFrame){
if(this.hitTest(root.character.x, root.character._y, true)) {
if(Key.isDown(Key.LEFT)){
setProperty(
root.background1, x, (root.background1.x – 4));
}
if(Key.isDown(Key.RIGHT)){
setProperty(
root.background1, x, (root.background1.x + 4));
}
if(Key.isDown(Key.UP)){
setProperty(
root.background1, y, (root.background1.y – 4));
}
if(Key.isDown(Key.DOWN)){
setProperty(
root.background1, y, (_root.background1.y + 4));
}
}
}

Where background1 is the background (I move it rather than the character) and character is the main person, that is moved.

It works relatively fine, but when the shapes are a little more complex the character can rebound “into” the walls and get stuck in there. How would you reccomend doing hitdetection?

 
Flag Post

Topic: Game Programming / [AS2] Camera's x and y

Thanks!
I had a friend who hadn’t coded in a while when he taught me, I guess setProperty must have become archaic :P

Though I swear root.target._y = 10 used to not work, like 3 years ago. I guess I must be crazy ^^

As you can probably tell by the stupid questions, I haven’t coded in a while :P

 
Flag Post

Topic: Game Programming / [AS2] Camera's x and y

Thanks! I just picked up a really old project that is in AS2 and wanted to finish it. I hadn’t gotten very far into it, but still. I’m learning AS3 after this – probably will just start with the Shootorials. Never done them, but they’re AS3, right.

I’ve been using setProperty (“_root.(target”), _x (or _y), (amount)) for some other things, that work fine, doesn’t it?

Thanks for the help :)

 
Flag Post

Topic: Game Programming / [AS2] Camera's x and y

I couldn’t find a tutorial on this, and I don’t think it’s possible, but it would solve a problem nice and easily for me :P

Is it possible to directly move what you are looking at’s x and y? As in not the target you are looking at, move the x and y location you are looking at.

Because at the moment when you come out of the building, I use setPosition to change your _x to not be in the door (and create an eternal loop) but that offsets you from the centre of the camera.

Anyway, I think it’s a long stretch, but worth a shot :P
:)

 
Flag Post

Topic: Game Programming / [AS2] Problems with code [SOLVED]

Thanks! It was a double-problem, the instancename deposit wasn’t working either, so I just changed it to abcd and it worked fine!

Sorry about the dumb questions, I haven’t used AS in several years – I last used it when I was 12. As you can probably tell, I’m creating an RPG well, recreating Stick RPG and even though I’ve had a couple of stupid moments like this, it’s actually coming along pretty well.

So thanks everyone for your help!

 
Flag Post

Topic: Game Programming / [AS2] Problems with code [SOLVED]

Sorry, I was hiking in Malaysia. I have declared all my variables (both A and B) as numbers already, but I have to specify that it is a number when calling?

B = B + Number(A) and B += Number(A) both don’t work (B changes to Not A Number). I already have declared them as a number when declaring the variable, like this :

var B:Number = 0;

on the setup screen (which is only accessed once so it’s not being re-set to 0)

 
Flag Post

Topic: Collaborations / Programmer Needed [Paid]

I feel for you. Alberto2121’s post isn’t even in proper English, and it is a huge necro. I hope it went/will go well.

 
Flag Post

Topic: General Gaming / YAGRPG (or, Yet Another Generic Role Playing Game)

Now, with a title like that, I’ve got your attention. The description on the game pretty much says it all. I’ve updated it with 2 large (compared to the original size of the .swf :P) updates in 3 days, but I’m leaving for a 4 day camp. I haven’t coded in some time, but I feel that it is at a point where it is good to show what the game will become. Most of the underlying stuff is done, now I just need to add in a whole bunch new content, but that is why it is a proof of concept more than an actual game.

And don’t worry about the terrible graphics, I have someone more artisticly gifted than me working on an update for them.

Here is a link:
http://www.kongregate.com/games/Arcaian/yagrpg-proof-of-concept

I hope you give it a try! It’s not much , but I think it is at a point where I can show you what it will be.

Thanks for reading!

Arcaian
 
Flag Post

Topic: Game Programming / [AS2] Problems with code [SOLVED]

Thanks! Stupid me. I wonder why I don’t need to do that in buttons…

One last (probably retarded) question.

I have two variables, a and b. A is derived from an input text box. I want to add a to b, and I’m not sure why this happens:
Input box = 3 , therefore a =3.

B = B + A

If B is 0, then B = 0 + 3 = 3.
Or, B += A
0 += 3
=3

However, it does not work this way. Instead, it works by adding 0 and 3 to make 03, and then it will not work further. I have no idea why.

It works if I replace A with a set number.

 
Flag Post

Topic: Game Programming / Eclipse nexus - Free 2D mmorpg maker Engine

To be honest, it doesn’t look very proffesional. At all. In fact, it makes me think it either doesn’t work or is malicious.

Try improving your spelling, making the page look neater and posting some demos or videos made with the engine.

 
Flag Post

Topic: Game Programming / [AS2] Problems with code [SOLVED]

I’ve tested a little further and found the following:

if(skateboard == true):

Does not work, on a MovieClip.

if(skateboard == true):

Does work on a button.

Now, I’m confused.

 
Flag Post

Topic: Game Programming / How to do A RPG Turn Based Flash AS3

I still code in AS2 (I learnt it years ago, forgot it and started again, but still don’t like AS3 :P) but if the saving system in AS3 is similar to that of AS2, saving is actually rather easy.

 
Flag Post

Topic: Game Programming / [AS2] Problems with code [SOLVED]

Also, I have tried this as well:

if(Key.isDown(Key.SHIFT) && skateboard == true){
trace(“skateboard works”)
this.gotoAndPlay(2);
}

 
Flag Post

Topic: Game Programming / [AS2] Problems with code [SOLVED]

EDIT: New problem!

I have 2 variables, deposit and inbank. I have a setup phase to my game (declares the variables, stats are chosen, name is picked) and I have declared both variables there. I declared them like this:

var deposit=Number: 0;
var inbank=Number: 0;

And then there is a bank screen. There is an input text box with the variable “deposit” (not with the "" though), a dynamic textbox with the variable inbank and a button with the following code:

on(release){
inbank = inbank + deposit
}

My problem occurs when I type in a number to the input textbox – say 5. I then click the button, and inbank goes from being equal to 0 to being equal to NaN (not a number).

This I don’t understand .

I have been recommended to use int() or number() but I don’t understand where these would be placed. Thanks for your help!

 
Flag Post

Topic: Kongregate Labs / Moving Background

I’m trying to do a different version of the moving background , I would like it to move WHEN the ship/char/car/whatever gets there ? Is there anyway to do that anyone knows ? And also is there some way so that you can make a sound go when you press a button ? And ( sorry for all the troube , lol ) Can you make it so your " ship " rotates when you turn ?

Let me explain , I am making a car game . I don’t want the thing to look stupid when going sideways and backwards . I would like a horn , and I don’t want a constantly moving background – it pressures the user too much . So is there anyway ( or any site ) that these can be fixed at ?

 
Flag Post

Topic: Kongregate Labs / Shootorial 5 Help -Arcaian

Well , nvm , I’m stopoing . Just working on getting better on the beggining bits now , but none of them worked , lol .