Recent posts by ErlendHL on Kongregate

Flag Post

Topic: Game Programming / [Solved] Textfield doesn't show.

Thanks! Setting the text last did it.

 
Flag Post

Topic: Game Programming / [Solved] Textfield doesn't show.

I have a class where I embed a font like this:

[Embed(source = '../04B_03__.TTF', fontFamily = "04b03", embedAsCFF = "false", unicodeRange = "U+0020-U+00FF,U+2018-U+201E,U+2022,U+20AC,U+2122")] private var totallyUselessString:String;

In the constructor:

textField.text = text;
textField.embedFonts = true;
textField.defaultTextFormat = new TextFormat("04b03", 16, 0xFFFFFF);
textField.selectable = true;

But the text doesn’t show at all. Now, if I comment out embedFonts, then the text does show, but it’s written in some standard font, and it’s also black.

 
Flag Post

Topic: Game Programming / [Solved] Input text field acts weird when not put on stage.

Actually, that did it, Aesica, thanks.

 
Flag Post

Topic: Game Programming / [Solved] Input text field acts weird when not put on stage.

I am making a virtual front-end desktop simulator for my game. I have a “program” Chatroom (that is, a class), that I can run in a window. It is not a display object. It contains an input TextField for writing in text.

I have several problems.

1. The text pointer is invisible. That line that is supposed to blink where you are writing in the input text. Additionally, there’s a point somewhere else on the screen that blinks and acts like the input line – i.e it moves forward when you write.

2. The text in the input textfield does not scroll when you reach the end of its boundaries. It stays in place. The expected behaviour is that it scrolls such that the input line is always on screen.

The input textfield is drawn to a BitmapData using draw(), and then that bitmapdata is drawn to the screen. I am aware these problems it’s probably due to the fact that it’s not actually attached to the screen, but is there some way to work around this?

public function Chatroom(parent:Desktop):void
{
	super(100, 100, size.x + margin + 10, size.y + margin + 10, parent);
	
	inp = new TextField();
	inp.type = "input";
	inp.embedFonts = true
	inp.defaultTextFormat = new TextFormat("Code", 16, 0xFFFFFF);
	inp.selectable = false;
	inp.wordWrap = false;

I also have this in my update function:

// If windows is focused, focus input text
if (parent.getWindows().indexOf(this) == parent.getWindows().length - 1 && Main.stage.focus != inp) {
	Main.stage.focus = inp;
}

Without that, I cannot input anything at all.

Thanks.

 
Flag Post

Topic: Game Programming / [Solved I think] How to _copy_ semi-transparent pixels?

Originally posted by Amibtious:

Possibly something to do with the corners being calculated in twips rather than whole pixels.

You could just draw the rect with 0×094509 in the first place?

I don’t think so – remember that this is my own implementation, and I do it pretty straightforward the way I told in OP. Afaik I don’t use twips but I’m a bit unsure about the definition.

  1. Make a temp bitmap the size of the circle
  2. Draw the circle with temp.setPixel32(…) with the colour passed (0×88-etc)
  3. Copy the quadrants of the temp bitmap directly to the screen using copyPixels.

Regarding drawing the rect with precalculated colour: I might as well do that. It would be better to fix this issue but it’s a temporary working fix.

Edit: I solved it by making a secondary temp BitmapData that doens’t support transparency, and copied the original temp bmd to that secondary bmd. Then I used that secondary bmd as alphaBitmapData in copyPixels. The fault must have been that when copyPixels is told to use the same alpha bitmapdata as the original bmd, it takes in consideration both the sourceBitmapData and the alphaBitmapData’s alpha values when interpolating colours.

 
Flag Post

Topic: Game Programming / [Solved I think] How to _copy_ semi-transparent pixels?

I have an implementation of a circle drawing algorithm (I desperately needed nice pixel circles in my game..). I made a function to draw a round rectangle.

I want to draw a round rect with colour 0x88108010 to a black background. The colour should obviously blend with the background.
First, I draw a circle with radius r (parameter of the rounded rect) to a temporary BitmapData. The function does this using setPixel32.
Next, I copy each quadrant of the temporary BitmapData, to the screen; like this:

screen.copyPixels(temp, rec, somePoint, temp, someOtherPoint, true);

I also tried with false as the last argument, with no success. Well the problem, at last, is that the curves of the rounded rectangles seem twice as weak (apparently it’s blended twice with alpha value of 88).

The straight lines have the desired colour; the curves should be the same colour as them.

I have also tried only the 3 first arguments of copyPixels, but then the whole black square gets copied along, which is undesirable.

Thanks in advance.

 
Flag Post

Topic: Game Programming / Irc

Good points. I wish gdr was more active; when is it the most active?

 
Flag Post

Topic: Game Programming / Irc

We have the famous GDR but are any of you on IRC? What channels? Would it be a good idea with a new irc channel for this community?

 
Flag Post

Topic: Game Programming / Package system

Hi.
I need to use this class. However, I am unsure where to put it. In a com folder that is not dependent on any project, or would I copy it to whatever project directory I have? And how would I use it? Thanks.

 
Flag Post

Topic: Game Programming / [AGAL] Can't make this simple test work.

I wrote a small AGAL (shader language) test (using this), but it doesn’t really do anything. I’m intending to just move all the pixels by a certain amount. Edit: fc1.x is set to 13.

Pixel shader:

add ft1, v1, fc1 // ft1 = position + fc1
tex ft0, ft1, fs0 <2d,repeat,linear,mipnearest> // ft0 = the texture at position ft1
mov oc, ft0 // output ft0
 
Flag Post

Topic: Game Programming / [SOLVED] [AS3, FD] Font doesn't work in the class it's embedded in

Aye, thank you!

 
Flag Post

Topic: Game Programming / [SOLVED] [AS3, FD] Font doesn't work in the class it's embedded in

Hey! I just picked up my years-old project. I wanted to change a font. Here is the relevant project structure

src
    Pix (package)
         PixMap.as
    Chatroom.as

The font resides in Pix. I also tried moving it outside of Pix (and also removed the Pix/ from the Embed source) but still didn’t work.

Chatroom has this line in the beginning of the class:

[Embed(source = 'Pix/Coders-Crux-2.ttf', fontFamily = "Code", embedAsCFF = "false", unicodeRange = "U+0020-U+00FF")] private static var totallyUselessString:String;

PixMap has this function:

public function text(x:int, y:int, text:String, size:uint = 12, colour:uint = 0xFFFFFF, font:String = "Code"):Point
{
	var txtF:TextField = new TextField();
	txtF.defaultTextFormat = new TextFormat(font, size, colour);
	txtF.embedFonts = true;
	txtF.text = text;
	txtF.width = txtF.textWidth + 7;
	txtF.height = txtF.textHeight;
	pixmap.draw(txtF, new Matrix(1, 0, 0, 1, x, y));
	return new Point(txtF.width, txtF.height);
}

Inside Chatroom.as I draw one textbox with PixMap’s text function

pixmap.text(start.x + 10, start.y + 5, "Alpha beta", 16, white, "Code");

, and one input text box “inp” causually:

inp = new TextField();
inp.type = "input";
inp.defaultTextFormat = new TextFormat("Code", 16, 0xFFFFFF);

But only the first one – the one that I draw using pixmap.text – has the right font. The other one (inp) has some default font. I find this really weird, that PixMap seems to know the “Code” font while Chatroom – where the font is actually embedded – does not know it… If anyone sees a solution/error, thanks in advance! Cheers.

 
Flag Post

Topic: Game Programming / FDT for Eclipse - can't run my project

Btw, when running the swf in the flashplayerdebugger that I downloaded, I get this output: “./flashplayerdebugger: error while loading shared libraries: libgthread-2.0.so.0: cannot open shared object file: No such file or directory”. Whatsoever, FDT isn’t even using that debugger, as all I can choose as Debugger is Flex 4.6. So I ran the swf in Flex and I got this output. I don’t suppose any of you will know the solution to this; can’t even find any resources online >.>

Edit: I now see I have Flex 4.5 installed but in FDT I can only choose to use Flex FDT 4.6. no… that’s not true, sorry. It is 4.6 that I have installed.

 
Flag Post

Topic: Game Programming / FDT for Eclipse - can't run my project

I don’t know; I downloaded the debugger from here (Linux Flash Player 11.2 Projector content debugger (TAR.GZ, 6.16MB)), and when I unpack it it’s just a binary file. In Window → Preferences → FDT → Debugger, I can only choose Flex 4.6, not browse for a file or something.
If this helps, this is the output I get when eclipse starts:

[Bundle Adapters] Bundle installed: true
org.eclipse.swt.SWTException: Invalid thread access
	at org.eclipse.swt.SWT.error(SWT.java:4397)
	at org.eclipse.swt.SWT.error(SWT.java:4312)
	at org.eclipse.swt.SWT.error(SWT.java:4283)
	at org.eclipse.swt.widgets.Display.error(Display.java:1204)
	at org.eclipse.swt.widgets.Display.checkDevice(Display.java:759)
	at org.eclipse.swt.widgets.Display.timerExec(Display.java:4274)
	at com.powerflasher.fdt.internal.ui.update.FdtUpdateHandler$1.run(FdtUpdateHandler.java:56)
	at com.powerflasher.fdt.ui.FDTUIPlugin$3.run(FDTUIPlugin.java:272)

And this is when I press Ctrl + F11 to run it:

Primary Build Start storing temp data for Flash-test
Primary Build Storing temp data for Flash-test needs 2 ms.
[STDOUT]: Prop: /home/uint/.eclipse/org.eclipse.platform_4.3.0_1543616141_linux_gtk_x86_64/plugins/com.powerflasher.fdt.ui.swfViewer_1.13.391.1657/linux64/data/properties.xml
[STDOUT]: Id: primarySession
[STDOUT]: Could not instantiate Browser: No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]
[ERROR]: Exception in thread "main" java.lang.NullPointerException
[ERROR]: 	at com.powerflasher.swfViewer.MainWindow.setUrl(MainWindow.java:226)
[ERROR]: 	at com.powerflasher.swfViewer.MainWindow.initValues(MainWindow.java:185)
[ERROR]: 	at com.powerflasher.swfViewer.MainWindow.open(MainWindow.java:172)
[ERROR]: 	at com.powerflasher.swfViewer.SWFViewer.openMainWindow(SWFViewer.java:188)
[ERROR]: 	at com.powerflasher.swfViewer.SWFViewer.start(SWFViewer.java:29)
[ERROR]: 	at com.powerflasher.swfViewer.SWFViewer.main(SWFViewer.java:20)
 
Flag Post

Topic: Game Programming / FDT for Eclipse - can't run my project

Thanks for replying!
Running the swf in Firefox actually works :O
Here’s some output (over time) when I try to Debug instead of Run:

[Info] Listening to port 7935.
Using Flex SDK 4.5 Debugger Adapter.
[Info] Could not connect to the player, will try to connect for the next 72000 ms
[Info] Listening to port 7935.
[Info] Could not connect to the player, will try to connect for the next 64000 ms
[Info] Listening to port 7935.
[Info] Could not connect to the player, will try to connect for the next 56000 ms
[Info] Listening to port 7935.
[Info] Could not connect to the player, will try to connect for the next 48000 ms
[Info] Listening to port 7935.
[Info] Could not connect to the player, will try to connect for the next 40000 ms
[Info] Listening to port 7935.
[Info] Could not connect to the player, will try to connect for the next 32000 ms
[Info] Listening to port 7935.
[Info] Could not connect to the player, will try to connect for the next 24000 ms
[Info] Listening to port 7935.
[Info] Could not connect to the player, will try to connect for the next 16000 ms
[Info] Listening to port 7935.
[Info] Could not connect to the player, will try to connect for the next 8000 ms
[Info] Listening to port 7935.
[Info] Could not connect to the player, debug session stopped. Maybe you do not have the Debug Flash Player installed.

I have downloaded the flash debugger and placed it in /pkg in my filesystem. My friend adviced me to, and said there should be some settings in Run Configurations.. but I can’t find anything appropriate :/

 
Flag Post

Topic: Game Programming / FDT for Eclipse - can't run my project

Hi! I’m in Linux and just installed the free version of FDT in Eclipse.
I made a new Web project because I can’t find any other appropriate project type.

Web is inside New FDT Project. New FDT Project consist of AIR, Web, FDT Plugin and Haxe.

When I press CTRL + F11 to run the project, I get to choose between FDT SWF Application and FDT SWF Flex Unit Test, and I choose the former. (the latter is not available in the free license). I get this output:

Starting Launcher Flash-test-Flashtest.

Using: Flex SDK Compiler
Starting Incremental Build of Flash-test-Flashtest.

File /home/<username>/workspace/Java/Flash-test/bin/Flashtest.swf has not changed.
Build successful.

Launching External SWF Viewer

And it terminates it immediately. I put a trace in the Main constructor and it never gets called.
I need FDT to develop my ActionScript 3 project in Linux. (I have been using FlashDevelop earlier)

Thanks in advance!

 
Flag Post

Topic: Game Programming / Can Developers get a Kong chat room?

I am also regularily in #ludumdare and #1GAM. Especially #ludumdare is very active. . Edit: #ludumdare is seemingly not on freenode. I guess it’s on afternet then.

Originally posted by omutant:

the only question i have then is, what would the newbies like myself to programmers who knows their stuff ratio be in the chatroom?

Are you concerned there will be no good programmers in chatrooms? There are always a lot of people hanging around in irc chatrooms who are really good and helpful.

 
Flag Post

Topic: Game Programming / ...

You guys could at least be a little more gentle. Most of what I see here is hate and attempts to break him down. I love when people link to the Dunning–Kruger effect. Master suppression techniques like that makes me sick. Seems throughout the post you’re all conspiring to make him feel like a ball of mud. Well at least I would.

 
Flag Post

Topic: Game Programming / We have created a website where you can download code samples that show many different rendering techniques and effects!

Bookmarked! Great, thanks! <3

 
Flag Post

Topic: Game Programming / Awful Code [You've Written!]

I can’t get the code right now because it’s inside a fla, but I coded everything in timeline and in the “game” frame, I had one function for every level, and called them level1(), level2() etc up to like 20, and a (long) ‘algorithm’ using different counters … and ran levels by calling this["level" + currentLevel]();

 
Flag Post

Topic: Game Programming / Java Help?

The correct syntax here would be

public static void main(String[] args)
{
System.out.println("Welcome!");
// what
}

Although I really don’t understand what you meant with that if statement… You probably meant String() not str(). The ' means character, not string so use "
.. + what UG mentioned.

Pro tip: Read up on a language before writing in it ;)

 
Flag Post

Topic: Game Programming / Angular movement physics (no libraries)

It does seemingly work now, although I’m still not quite convinced.. but I guess I’m wrong in the end :p

I’m wondering about the relation between rotational and translational velocity unit. Right now, rotational velocity is given in radians per frame, and translational velocity is given in pixels per frame. I have to approach a number to divide the torque being added (which is 500 atm), so that it looks natural. Even if I was to use say m/s for velocity, what’s the ‘matching’ unit of rotation?

Right now, I’m using mass for moment of inertia. How do I calculate the moment of inertia?

 
Flag Post

Topic: Game Programming / Angular movement physics (no libraries)

Originally posted by Ace_Blue:
If instead you apply on the right edge of the circle, it is now normal to the line that connects the point at which you apply the force to the center of mass, so now the force is applied to the angular acceleration of the circle (it makes it rotate).

This is what I was trying to explain earlier. Looking at the code, I can’t make sense of it because it adds the force to the translational force no matter what; m_force += force;. So in that case you explained here, it would still do m_force += force, affecting the translational acceleration in the same degree no matter where the point of application is located.

 
Flag Post

Topic: Game Programming / Angular movement physics (no libraries)

Originally posted by NineFiveThree:
Originally posted by ErlendHL:

If I’m not completely wrong, -F1 would contain the same amount energy as F1 though. (imagine having two balls with zero velocity vs having two balls with the opposite velocity)

forces are forces, energy is energy.
a forces does not “contain” energy.

again, forces are not directly connected to velocity, but acceleration

Ah I misunderstood when Ace_Blue said the center of mass of the system is not affected. I thought he was talking about the conservation of energy.

Originally posted by NineFiveThree:
Originally posted by ErlendHL:

Anyway, what I was pointing to, is that it seems that the force you add altogether to the object (force + torque), exceeds the force you put in to the function. Because well, if you removed the torque part, then it looks more correct regarding the Conservation of energy rule.

How does it look more correct?

Well, when I apply a force to an object, I don’t expect it to be affected by more than the force that I put in. I mean when it’s only m_force += force;, then you’re already applying 100% of the force you put in. And then you additionally add some to the torque.

Originally posted by NineFiveThree:
Originally posted by ErlendHL:

E: Hm additionally, say you have a circle. You apply a force at the very right of the circle. The force is pointing downwards. This code will treat the force as if it’s positioned in the gravitational center. And that’s wrong because the force should have almost no impact on the velocity of the circle (mostly just rotation).

The gravitational center of a circle is not at the very right, but its center.

I know, but what I meant with this example, is that Box2D just adds the force like m_force += force;, not taking in consideration the point of the force. And I bet that m_force is considered to be positioned at the center of gravity. Maybe I’ve misunderstood something, but if there’s a force like I explained in the example, I don’t think m_force += force; looks right because most of that force would be used on changing the rotation (by being added to the torque), while the positional velocity shouldn’t be affected that much.

 
Flag Post

Topic: Game Programming / Angular movement physics (no libraries)

Originally posted by Ace_Blue:

Edit: \/ When two objects collide the force is applied at the point of contact, yes. And if you apply a force vector F1 to object 1 then you apply -F1 to object 2, so the center of mass of the system is not affected.

If I’m not completely wrong, -F1 would contain the same amount energy as F1 though. (imagine having two balls with zero velocity vs having two balls with the opposite velocity)

Anyway, what I was pointing to, is that it seems that the force you add altogether to the object (force + torque), exceeds the force you put in to the function. Because well, if you removed the torque part, then it looks more correct regarding the Conservation of energy rule.

E: Hm additionally, say you have a circle. You apply a force at the very right edge of the circle. The force is pointing downwards. This code will treat the force as if it’s positioned in the gravitational center. And that’s wrong because the force should have almost no impact on the velocity of the circle (mostly just rotation).