Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 18 Oct 2005
Online Last Active Today, 12:14 AM

#5157058 code flow (order) here

Posted by SimonForsman on 30 May 2014 - 05:00 PM

Allright, tnx, I will answet to it toomorrow (need a bit of thinking)

but i could ask yet one thing i do not understand in meantime


in oncreate in activity there is a line (80)


pongView = (PongTimeView)findViewById(R.id.pongview);


I do not understand this, pongView is an large object how you can just assign something to a large object - i would understand assigning something to a field of that but to a whole object - what is assigned here? does such assigning overvrite the left side, I mean previous state of an object - this line is strange to me; Can someone answer that?

(soory for font thuis changed after paste and i see no easy trick to change font tonormal)


pongView will store a reference to the view returned by findViewById. (R.id.pongview is a resource identifier so the view is most likely generated from an xml file)

if pongView allready had a reference to some other object the old reference would be dropped. (in this case that code should only run once when the activity starts).


consider this example


MyClass a = new MyClass();
MyClass b = a;
//Now a and b reference the same object.
a.someMember = 5;
System.out.println(b.someMember) //This will print 5 since a and b are the same object.
b = new MyClass(); //now b will reference a new object, a is unchanged.
b.someMember = 10;
System.out.println(a.someMember) //this will print 5 since a and b are different objects now
a = b.Clone(); // this creates a copy of b and assigns its reference to a, the original object referenced by a is no longer referenced by anything and will be garbage collected eventually. (Most standard library classes implement the Clonable interface)
System.out.println(a.someMember) //this prints 10
b.someMember = 15;
System.out.println(a.someMember) //this still prints 10 since a and b are different objects now.

#5156823 android fluid frames and gc

Posted by SimonForsman on 29 May 2014 - 03:08 PM


Since you didn't post any actual code it is hard to give a proper answer but.... yes, when you make games using Java(and other languages with a hard to control GC) you want to write your code in a way that keeps the GC from kicking in during gameplay. Hold on to your references, re-use allready allocated objects instead of reallocating them, avoid modifying immutable objects(such as strings) and try to do your cleanup (drop references and force the GC to run) during your loading screens,


Isnt this something you do against the language? Im a bit schocked. Is it really possible to not involve garbage collection in java? I mean it would be something like c style writing in java ;/


I understand that procedural c-like way of writing in java on android is impossible because of heavy objective api, or this is also possoble?


(sad I got no experience here, come from couple of years in pure c/winapi world, maybe I will learn something about this very crazy world of android this year ;\)


PS as to source i just wathing some very simple random pice of android game code 




and trying to get know what is going on here; 

If someone would like volountinery explain me a bit what is goin on here it would be welcome too...



No, its not possible to "not involve" the garbage collector, but it is possible to keep it from running when you don't want it to run. (The GC will not run(or will atleast run really really quickly) if there is no garbage to clean up) and you can coax the GC to run when you want it to run (By asking it nicely and sleeping repeatedly until it runs).


That code being ugly has nothing to do with the GC though (for a simple game like pong the GC is irrelevant as you can create all your objects at startup and hold on to them until the program closes)

#5156530 android fluid frames and gc

Posted by SimonForsman on 28 May 2014 - 12:30 PM

Since you didn't post any actual code it is hard to give a proper answer but.... yes, when you make games using Java(and other languages with a hard to control GC) you want to write your code in a way that keeps the GC from kicking in during gameplay. Hold on to your references, re-use allready allocated objects instead of reallocating them, avoid modifying immutable objects(such as strings) and try to do your cleanup (drop references and force the GC to run) during your loading screens,

#5151567 How to get rid of black borders in full screen? (OpenGL/Win32 API)

Posted by SimonForsman on 05 May 2014 - 03:36 AM

Create the "window" using the desktop resolution (you can get this from Windows) and pass the desktop resolution to glViewport but send 800, 600 to glOrtho. (or use 800,600 to create your own orthographic projection matrix if you use modern OpenGL)

#5149722 How can i save an image without edges?

Posted by SimonForsman on 26 April 2014 - 04:29 PM

A) add an alpha channel and erase the background, save the image in a format that supports transparancy. (.png is fairly popular)

B) pick one color(magenta is popular for this) to use as "transparent" and filter it out in your engine.

#5147630 Python 3 + Linux terminal

Posted by SimonForsman on 17 April 2014 - 07:48 AM

To open a new terminal from a python application you must start it in a new subprocess:


subprocess.Popen(['gnome-terminal', '-e'])
To communicate with the opened terminal you may want to use the pexpect library, it will help you write to the terminal stdin and get the terminal stdout.


That being said, I have no idea how you can retrieve an existing tty handle and write to its stdout.


os.ttyname(filedescriptor) gives you the ttyhandle, os.ttyname(sys.stdout) from the process owning the terminal should work (if the terminal is connected directly to stdout).

os.open(ttyname, flags) should provide a filehandle for reading/writing to a named terminal.

#5146985 Can't publish Android App from my country, can I use my friend in the US?

Posted by SimonForsman on 14 April 2014 - 03:31 PM


I see. I live in Slovenia.
Where could I find this kind of information / should I rather ask a lawyer in my country?

^^ this.

I don't know why you cannot publish it directly, but if you attempt to get around it you might be in serious trouble.

Talk with a lawyer and understand WHY you cannot publish, then understand the CONSEQUENCES of going through a third party.

Sometimes using a third party is perfectly acceptable, but you will need to pay taxes and governmental fees, as well as pay the third party for their services.

Sometimes using a third party is very bad, with the potential to have very serious legal consequences.

A lawyer who understands the law can help you understand what is involved, and help you manage the risks involved.



Google supports developer registrations from Slovena, they just aren't supporting merchant accounts from there yet(They are missing tons of countries and keep adding new ones at a very slow pace), There are no trade restrictions in place between the US and Slovenia(it is a EU country and even a NATO member).


Thus, the OP has 5 options:

1) Release the app for free.

2) Publish through a company in a supported country. (The OP can register a business in any EU country but AFAIK google only needs a bank account, if they need a postal address in a supported country the OP can register a business and get a virtual office in for example germany)

3) Wait, Google should add slovenia eventually. (their list of supported countries is slowly growing)

4) Publish the app through Amazon, Amazon supports sellers in the Eurozone(Which includes Slovenia) and the UK.

5) Get a bank account in a supported EU nation such as UK or Germany, Talk to your own bank or one of the bigger banks in Slovenia, they might have offices or partners in a supported country and thus they can set things up for you (One of the bigger swedish banks provide such a service for companies and individuals selling on Amazon through their german offices). If your bank can't help you then you'll have to contact a foreign bank yourself. EU banks are not allowed to refuse EU citizens from opening an account just based on their nationality (They can refuse based on where you actually live but plenty of banks do offer accounts to residents in other EU countries so it shouldn't pose a big problem if you shop around a bit)


I'd recommend selling through a EU country as you can move capital freely between EU countries. (Banks are not allowed to charge a higher transfer fee for EU transfers than they do for national transfers)

#5146819 watercyfle

Posted by SimonForsman on 14 April 2014 - 01:04 AM

If this is for school you really should do it yourself.


If it is not for school you should use the classifieds section if you want to hire a programmer.

#5146345 Can't publish Android App from my country, can I use my friend in the US?

Posted by SimonForsman on 11 April 2014 - 11:40 AM

I see. I live in Slovenia.


Where could I find this kind of information / should I rather ask a lawyer in my country?


I don't think the US has any trade sanctions against slovenia so it should be legal, as long as you both pay any applicable taxes properly.

#5146238 Static as substitute of private members.

Posted by SimonForsman on 11 April 2014 - 07:12 AM


Static is not a replacement for private in C. Declaring and defining them only in the .C file is.


Don't they need to be declared static inside the .C file so that they only visible from within that compilation unit.



No, each compilation unit is compiled individually, a variable has to be declared as extern to become accessible across compilation units.


Edit: Sorry, obviously incorrect.

#5146035 Unreal supports Linux

Posted by SimonForsman on 10 April 2014 - 12:16 PM

On the gaming consumer side:
Hopefully SteamOS isn't really that different from other Linux distros, so that SteamOS-compatible games would run on Ubuntu, etc.

It is just a trimmed down debian based linux distribution with the steam client, Real time kernel patches and a custom compositor, from an applications point of view it is just another debian based OS.

Players should get less input latency and better transitions between the games and the steam overlay. (It does sacrifice some throughput to get the lower latencies though so in some games the framerates are slightly lower than in Ubuntu or Windows 8)

#5145452 How does java find sine and cosine?

Posted by SimonForsman on 08 April 2014 - 01:21 PM

I did a bit of research, and it appears that Java SE provides two math libraries: StrictMath and Math. StrictMath uses a software implementation, whereas Math may use intrinsics as dictated by the JVM at runtime. If an intrinsic isn't available for a specific function, Math will call StrictMath's equivalent.

In short, use StrictMath if determinism is more important than speed, or use Math if speed is more important than determinism.


It is up to the implementation for both classes, the only difference is the required accuracy. (StrictMath must give the exact same result on all platforms(Oracle has a reference library with a compliant software implementation). For the normal math class the error must be less than 0.5-2ulp (varies between methods in the class).


on x86 StrictMath uses a software implementation and Math does a software argument reduction (if you pass big arguments to your trig functions) before using the native instruction. a comliant JVM is free to handle things differently on architectures with more accurate trig instructions.

#5144445 Estimating the revenue of a mobile game?

Posted by SimonForsman on 04 April 2014 - 03:18 PM

Add up your costs, then multiply by negative one. That's your revenue estimate.

Until you have sales or presales data you cannot possibly extrapolate revenue. There's nothing to extrapolate.


Thats wrong. the revenue estimate should be: (pricePerCopy-appstorecut) * 0

the cost estimate is simply: sum(costs)

The profit estimate would then be: ((pricePerCopy-appstorecut) * 0) - sum(costs)

#5144340 Learning Unity

Posted by SimonForsman on 04 April 2014 - 07:31 AM


Im a bit confused though,




Use the Java course if you're wanting to get into C# right away, but honestly I'd just stick to Java since you can use that in Unity instead of C#,


Java is used inside C# ?


Just ignore that one, he is obviously confused aswell.


To clarify:


Unity supports 3 languages,


Boo - a .Net language related to python

UnityScript - a Unity specific derivate of JScript.Net (Which in turn is Microsofts .Net adaptation of JavaScript).


Java on the other hand is a completely different language which is quite similar to C# (But not supported  by Unity3D)

The name confusion is most likely the result of marketing drones at Sun(The company that created Java) and marketing drones at Netscape(The company that created JavaScript) eating/smoking/injecting illegal substances.

#5143443 Linux development...

Posted by SimonForsman on 31 March 2014 - 05:55 AM

I am new to Linux and any development on it.


I have a Radeon X1300 GPU, and will be coding C/C++/OpenGL/SDL2 or SFML2


I need some recommendations for IDE under Linux.


I am running Linux Mint 16...


QtCreator? If I remember right the UI wasn't to friendly to get a simple C++ project working....


How do I install the latest drivers for this GPU? From what I can tell the latest don't support the X1300?


What is X11? Do I need it?


I would like to use Irrlicht also but couldn't get that working either.


So I am not liking the experience so far... Not trouble free at all....




Hope to overcome the sour taste of this and enjoy coding on Linux but need some serious help!!!


The x1300 is no longer supported by AMD, they cut Linux support in 2009 (4 years after the first x1000 GPUs hit the market) and Windows support a few years later (there is no Win7 or 8 driver either (The vista driver works in Win7 though, and you can hack it to work in Win8) so you have to use the opensource driver that is included in your distribution, or use a very old(2009 or older) distribution.

Overall AMD tends to cut support really quickly for their hardware on Linux but their opensource drivers are decent, nvidia is the exact opposite (their proprietary support lasts a very long time(10+ years normally) but their opensource drivers are pure junk by comparison)


Edit: You don't have to install the opensource driver yourself, Mint installs and updates it for you automatically.


If you want better performance or more features than the opensource driver provides you have to either switch to an old distribution (IIRC Linux Mint 5 is the newest Mint version that works with the proprietary x1300 driver) or buy a new GPU (or an older nvidia GPU as nvidia supports their GPUs for far longer than AMD does)


Just for comparison, nvidias GF5 to GF7 series (The GF7 was the direct competitor to ATIs x1000 series) will get updated to support new linux distributions(and Windows versions) or to fix critical bugs until the end of 2017 and the GF2-GF4 series got their final update in december last year (and thus still work with most recent distributions and have a proper Win8 driver), the GF8 - 280 will be supported until 2019. (Later GPUs don't have a EOL date set yet but should be supported for atleast 10 years from when they were first released)