Recent posts by evan999333 on Kongregate

Subscribe to Recent posts by evan999333 on Kongregate

avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / [AS] Help with scroll text boxes and variables.

You should stop editing and just replying by the way… Im answering your questions that you keep editing over. If someone else has a similar problem or similar questions it would be good if they could see what your asking so the answers i’m giving have context.

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / [AS] Help with scroll text boxes and variables.

Scroll event should look like this.

yourMoveclipThatContainsYourText.addEventListener(MouseEvent.MOUSE_WHEEL,mouseWheel);
public function mouseWheel(event:MouseEvent)
		{
			if (event.delta == 3)
			{
				yourMoveclipThatContainsYourText.y -=  scrollYOffSetScrollSpeed;
			}
			if (event.delta == -3)
			{
				yourMoveclipThatContainsYourText.y +=  scrollYOffSetScrollSpeed;
			}
		}

Where scrollYOffSetScrollSpeed is the height of 1 line of your text box. Also add a if statement to make it so the person can’t scroll it any higher than the top text or any lower then the bottom text box.

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / [AS] Help with scroll text boxes and variables.

You can make your text box have a mask that only displays 1 line at a time. Add an event listener for a click on the text box to get ‘focus’ (optional) and add a scroll event to make the object that cointains your text move up or down each time the scroll wheel is turned. If that doesn;t make sense I can whip up an example for you.

As for displaying the text in the single text box to get a new line in a string you type "text1"+"\n"+"text2"
So for your example
var goldVar:uint = 1
var silverVar:uint = 10
var bronzeVar:uint = 20

textBoxText.text = "Gold “goldVar”\n"+"Silver “silverVar”\n"+"Bronze "+bronzeVar

Will display in a text box thats big enough


Gold 1
Silver 10
Bronze 20

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / About curly braces

I like the second personally
Edit>Preferences>Autofomat
check “Inset { on line after if, for, switch, while, etc.”

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / Falling through floor

There is AS3 version with the AS2

Sorry I just pasted the link but it looks like a good way into the tutorial it switches to AS3

The AS3 starts here http://www.emanueleferonato.com/2008/09/25/new-tile-based-platform-engine-as3-version/

So I guess just read through the first 5 parts and get what hes doing.

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / Falling through floor

http://www.emanueleferonato.com/2008/09/14/new-tile-based-platform-engine-part-1/
Although some people say this site/persons tutorials are questionable if you are new its a good place to start. Go through the whole tutorial and you will be able to make a platform game.

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / Falling through floor

Or hitTestPoint for a better result non flat terrain (like if you wanted slops this could let the player walk up the slope just fine and if you have a gravity var it will allow the player to walk down the ramp)


while (floor.hitTestPoint(player.x,(player.y+variableForHalfPlayerHeight),true)
{
player.y – -
}

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / How would you do this

Ah that makes sense thank you everyone.

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / How would you do this

What do you guys mean by “normalise?”

Also I don’t really understand what NineFiveThree is saying with

“if the sum is bigger than the random Number, pick the current element.”

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / How would you do this

I have 6 varibiles


x1:int
x2:int
x3:int
x4:int
x5:int
x6:int

They can be set to any number really but for the sake of this example Ill give them some random ones.

x1:int = 4
x2:int = 2
x3:int = 3
x4:int = 6
x5:int = 5
x6:int = 3

These numbers represent chances of colours getting picked.

Red corresponds with x1
Orange corresponds with x2
Yellow corresponds with x3
Green corresponds with x4
Blue corresponds with x5
Purple corresponds with x6

So out of all the colours red for instance has a 4 in 23 chance of getting picked. (Because red is represented by x1 (4) and x1+x2+x3+x4+x5+x6 = 23, aka 4 in 23)

I’m going to create 6 new variables to represent these chances as a visual (this may not be necessary in your solution)


y1:int = 4/23
y2:int = 2/23
y3:int = 3/23
y4:int = 6/23
y5:int = 5/23
y6:int = 3/23

What I need is a way to randomly pick and output red,orange,yellow,green,blue, or purple based on their chances of getting picked (the x values.)

Any ideas?

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / [AS3] OOP Question

So I read that as

In a Main class you want to create a inventory item.
So in Main you create a inventory item
And depending on what that inventory item is – it has a different class applied to it.
And so you will have a new class for each inventory item and apply it to the corresponding item created?

Is this correct? If it is not then use psudo code to type out exactly what you want to do. If that is correct then you are going about this all wrong (or at least not how >I< would do it.

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / [AS3] OOP Question

I don’t really understand what you are trying to do but If you could explain it a bit better I might be able to help.

(Also it’s never to late to learn AS3 :D)

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / Creating A Loading Screen From A Swf

Thank you BigJM and SumGato (for explaining how use fix what BigJM pointed out.) Works perfectly.

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / Creating A Loading Screen From A Swf

I don’t quite understand what you’re saying…

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / Creating A Loading Screen From A Swf

Ok so I created a new .fla and put that in the timeline (although I would is possibile like to avoid timeline code) and got an error when trying to reference the stage in my ‘real’ swf file.

TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at Main()[C:\Users\Evan\Desktop\Tile Rouge Like\Main.as:563]

And that line is


stage.addEventListener(MouseEvent.RIGHT_CLICK, function(e:Event){});

Any ideas on whats causing that error or how to not have timeline code?

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / Creating A Loading Screen From A Swf

I was looking online for a tutorial on how to create a loading screen. However I have only seen examples of creating loading screens where a loading bar is put on frame 1 and everything else in the game happens on frame 2.

Somewhere I also came across someone saying that you can load a swf from another swf and avoid the need to have a second frame, but I could not find code or an example of how this is done.

Does anyone have an example of creating a loading screen/bar in this way or in some way that does not require code on the timeline or more than 1 frame?

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / A* (Star) Pathfinding (AS3) - Example

How could I run the algorithm without making the function calls I make? Do you mean I put the code from my functions into the 1 function that finds the path?

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / A* (Star) Pathfinding (AS3) - Example

Hrm I just fiddled around with it for a good 10 minutes doing everything I could think of and always getting a proper path. I have no idea how it can sometimes make a incorrect path like what you guys found. This is going to bug me. If anyone has any ideas I’d love to hear em.

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / A* (Star) Pathfinding (AS3) - Example

Originally posted by RTL_Shadow:
Originally posted by evan999333:

That is correct

Even if it were incorrect, it’s still impractical. What if you had no code completion, would you want to type that each time?

What do you mean “code completion?” I do type my functions out… Like I said I find they help me organize my code.

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / A* (Star) Pathfinding (AS3) - Example

That is correct

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / A* (Star) Pathfinding (AS3) - Example

Hah I never pressed the same point as where the enemy was… Well yes thats a easy fix no big deal.

Also where are you talking about to many function calls?

Lastly the length of the name of functions or variables don’t affect performance at all any more. I think its very practical as well as it tells me exactly what the function does. I find it useful but it could really be anything.

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / A* (Star) Pathfinding (AS3) - Example

… UnknownGuardian and Dealmaster13 I have no idea how that happened… I tried the same set up and got these paths.
http://gyazo.com/38a778ccf7d95d907f51fc72863adbd6
And
http://gyazo.com/2090c2a24f37f24c11a0e7d39104dc07
(It did not make 2 paths for me. The second path is made if you add a tile and it recalculates. I’ll fix that.)
I have no idea how thats possible

Edit: The visual showing of 2 path is fixed here but thats just visual and had nothing to do with the calculation so i have no idea how I have a different path than you guys.
http://www.fastswf.com/l_VHRg4
http://pastebin.com/Lv3Q7m30

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / A* (Star) Pathfinding (AS3) - Example

I found out a very big flaw that I neglected to fix. The enemy would always be hugging the wall and moving diagonally even if it was not the best path. If you want to see what I mean make a triangular dip and see how the enemy follows it along the wall all the way down in the first swf.

With just a few lines I fixed this problem.

New swf:http://www.fastswf.com/01W7maI
New paste bin:http://pastebin.com/Xi4n5acZ

(I’v also allowed it to partially go through walls but in the code I commented how you can turn this on or off if you never want the enemy to touch the wall ever)

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / A* (Star) Pathfinding (AS3) - Example

The past few days I have been working very hard to get a ‘clean’ version of A* pathfinding working.

I have looked online and found many useful tutorials (this one being the biggy http://www.policyalmanac.org/games/aStarTutorial.htm) that helped me finally wrap my head around the concept and get to my end result located here http://www.fastswf.com/9tenFt4

However in my searches I could not come across any flash source code that fit what I wanted.
- 1 Class
- Tile array used to build the level is 1D

So I’v figured it out and am just sharing in case anyone was interested.

The code can be found here http://pastebin.com/akZp6HWP and is HEAVILY commented for your convience.

If anyone has worked with A* before and knows of some optimizations or if anyone wants to give some feedback on my method I would like to hear it :D

 
avatar for evan999333 evan999333 322 posts
Flag Post

Topic: Game Programming / AS3 Quick Question About Parameters

In a my current project my options menu allows for rebindable keys. To do this all the keys used in the game are repersented by a varbile


private var jumpKeyBindVar:int = 87;
private var leftKeyBindVar:int = 65;
private var rightKeyBindVar:int = 68;
private var downKeyBindVar:int = 83;

So in my options menu if the player changed the key they want for jump to instead be 87 (the W key) to the space bar (32) having a reference to e.keyCode (aka the key being pressed) lets me do this.

function keyIsUp(e:KeyboardEvent):void
{
if (e.keyCode == jumpKeyBindVar)
{
upKeyIsDown = true
}
if (e.keyCode == downKeyBindVar)
{
downKeyIsDown = true
}
if (e.keyCode == leftKeyBindVar)
{
leftKeyIsDown = true
}
if (e.keyCode == rightKeyBindVar)
{
rightKeyIsDown = true
}
}

Stick with AS3 its awesome