Jump to content

  • Log In with Google      Sign In   
  • Create Account

SimonForsman

Member Since 18 Oct 2005
Online Last Active Today, 02:53 PM

#5199193 Is it possible to use Dart lang for Apach server?

Posted by SimonForsman on 19 December 2014 - 07:35 PM

It sounds like the OP wants to use a Dart client with a PHP server and communicate between them, which would mean that the server really is irrelevant.




#5198291 Is Java a good Language for Games?

Posted by SimonForsman on 15 December 2014 - 05:39 AM

        I am quite experienced with Java, i made several bukkit plugins and a few complex programs. I already have almost 2 years with Java as my main programming language. From my point of view i am quite ready to start game development. So here is my question. Is Java a good programming language for game development?

         I already read a lot of articles that there is no "special language for game programming" and that you should use the one your more comfortable with. But In my expirience making programs with java and deploying them was quite awful, i had to create a launcher with launcher4j and this wasnt working always also there were some permance issues(maybe my fault) but Java doesnt and compatibilities with the JRE.

        I tried C# with XNA Framework and it was quite intresting because of my experience with java and Java and C# similarities it was quite easy for me. So I should stick with Java with Slick2d to make a 2D game or I should use C# with XNA? Although i dont know hows XNA deployment.

Thank you

 

Here are some useful tips for Java performance: 

 

1) Avoid dropping references inside your game loop and try to allocate outside it when possible, re-use objects from a pool instead of reallocating inside your game loop. (The garbage collector is a huge source of Java performance issues, you want to keep it from running inside your game loop and the only way to do that is to not generate any garbage), if you generate garbage while the app is loading you can attempt to force the gc to run before entering the main loop by abusing weak references, sleep, and the system.gc() method (The spec doesn't guarantee that it will work but in practice it works on most JVMs, just make sure you limit the number of attempts made)

 

2) Strings are immutable, a new string will be created and the old one garbage collected if you modify a string, use stringbuffers if the text has to change inside your game loop and stringbuilder to assemble longer strings.

 

3) Always reserve space in your containers when you create them (this avoids expensive allocations/re-allocations when you fill them with data), use the right container for the job (Lists have horrible cache performance and are almost always the wrong choice)

 

4) trig operations in Java require a precision that x86 cpus fails to match outside the -pi/4 - pi/4 range, Java will do a very accurate and fairly expensive argument reduction for values outside that range on x86, the further you stray from the accurate range the slower those calls become so it helps to keep angles within the -PI - PI range (instead of the 0 - 2*PI range or -infinity - infinity range)

 

5) Native calls are quite expensive in Java, if you have to use native functionality you should write or use a fairly high level native library rather than wrapping low level native functions directly.

 

6) Don't use dynamic dispatch if you don't need it, even though it is cheaper than in native languages it usually isn't free.




#5196212 Accurately estimating programming cost?

Posted by SimonForsman on 04 December 2014 - 03:15 AM

The easiest way to estimate the cost of any project is to break it down into smaller parts and then make an estimate for each part based on your experience with similar tasks in other projects.

 

If you are buying services you should ask the contractors for an estimate and check their references.




#5196071 Weird stuff happening when stepping through a threaded code

Posted by SimonForsman on 03 December 2014 - 08:33 AM

 

first of all, your code is not thread safe, calling AddNewPath, GetPath, IsJobDone or RemoveJobresultAt while your thread is running is likely to end badly.

 

Multiple instances of AstarManager will also share data but run their own threads (again, without synchronization this will result in wierd bugs, if you are entering the update method multiple times then you are most likely creating multiple instances of AstarManager)

 

 

Edit: You havn't solved anything, Calling the thread twice only made the race-conditions more likely to occur, your code still isn't thread safe and thus can explode pretty much at any time. (Whenever you call a static method on AstarManager there is a small chance that it will blow up in your face as they modify data that the update loop assumes remains unchanged during an iteration)

 

 

My intention is to call the AstarManager once and never more than once. and then through the life duration of my software I would add jobs and remove them when they are done.

 

My understanding is that my code is thread safe unless I call AstarManager more than once. which I will not do.

 

just out of curiosity. what do I have to do to make my code thread safe? what am I doing wrong?

 

 

To make your code thread safe you should remove all statics(they make things far more complicated and don't really serve any useful purpose in this case) and ensure that all data manipulation is either synchronized or strictly controlled.

 

consider this method:

public static void AddNewPath(Node StartingNode, Node TargetNode, Map map, bool DisableDiagonalPathfinding, int JobNumber)
{
    for (int i = 0; i < AstarJobsList.Count; i++) //lets say that AstarJobsList.Count is 8 here
       //your main thread is happily running this loop, it is on its last iteration and i is 7 (still perfectly ok).
        // your update thread completes a job and removes it from the AstarJobsList (this doesn't look good)
        if (AstarJobsList[i].JobNumber == JobNumber) // AstarJobsList[i] no longer exists, booom !
            throw new ArgumentException("A job already exist with this JobNumber: " + JobNumber, "JobNumber");
        AstarJobsList.Add(new AstarJob(StartingNode, TargetNode, map, DisableDiagonalPathfinding, JobNumber));
}



#5196067 How does NVidia CP work?

Posted by SimonForsman on 03 December 2014 - 08:03 AM

It doesn't, it is basically a driver hack and nvidia has a list of games for which a given hack(such as AO) works, support for new games is added with driver updates. (nvidia added AO support to starcraft 2 wings of liberty in the R265 driver for example)




#5196066 Weird stuff happening when stepping through a threaded code

Posted by SimonForsman on 03 December 2014 - 07:46 AM

first of all, your code is not thread safe, calling AddNewPath, GetPath, IsJobDone or RemoveJobresultAt while your thread is running is likely to end badly.

 

Multiple instances of AstarManager will also share data but run their own threads (again, without synchronization this will result in wierd bugs, if you are entering the update method multiple times then you are most likely creating multiple instances of AstarManager)

 

 

Edit: You havn't solved anything, Calling the thread twice only made the race-conditions more likely to occur, your code still isn't thread safe and thus can explode pretty much at any time. (Whenever you call a static method on AstarManager there is a small chance that it will blow up in your face as they modify data that the update loop assumes remains unchanged during an iteration)




#5195089 Health bar graphics instead of text

Posted by SimonForsman on 27 November 2014 - 08:09 PM

I want to make my game display a health bar instead of plain text, how would I properly go about this? 

 

that depends on how you want it to look, the easiest would probably be to draw a quad/rectangle that is: maxwidth * (currenthp / maxhp) wide




#5194799 SDL Pausing game help?

Posted by SimonForsman on 26 November 2014 - 12:03 PM

I know this might sound stupid but what is the best way to go about pausing my game by pressing esc. I need it to pause everything then resume once i repress that key. Many thanks!

 

set paused = true when esc is pressed, don't update your game state if paused is true.




#5192891 How to repost coldfusion post variables in a 3rd page

Posted by SimonForsman on 14 November 2014 - 02:39 PM

if cold fusion supports sessions you can use that to store data, if not you can always have a form with hidden fields containing all the data on page2.




#5190878 Vertically scrolling underwater game, what to use as background?

Posted by SimonForsman on 03 November 2014 - 04:59 AM

 

I'm working on an endless-runner-game type game where the player has to catch coins and avoid bombs. It's underwater in the ocean and the scrolling direction is downward. The player moves towards the ocean floor, except it's like an endless pit and he will never actually reach the ocean floor.
 
The problem is that I don't know what to display as a background, because in open water there are no plants or rocks. wacko.png With a horizontally scrolling game this is easier because you can show plants or the floor moving. The enemies slowly move upward ofcourse, but I don't think that's enough to convey the downward scrolling motion...
 
Any tips or ideas will be much appreciated. Or does anyone know any underwater vertically games like this that I can take a look at?

 

 

I would put things like fish, cliffs, etc in background.




#5181344 Can you explain to me this code !

Posted by SimonForsman on 18 September 2014 - 01:26 PM

it will run & i know it is simple but why when i type 55
the result:
Man, learn to type a number. Good job! (why i get this result )
why i the result not  dead("You greedy bastard!")
Sorry Lysy but when i type the numbers i get many questions

if "0" in choice or "1" in choice:
    how_much = int(choice)
else:
    dead("Man, learn to type a number.")
the first line in that part checks if the text you've entered contains "0" or "1" , if it does it will try to convert the text to a number and assign it to the how_much variable , it the text doesn't contain 0 or 1 it will run the dead function with "Man, learn to type a number." as its parameter.

"55" doesn't contain 0 or 1 so it will run the dead function which prints the parameter "Man, learn to type a number." followed by "Good job!" and then it exits.


#5179020 C++ starter

Posted by SimonForsman on 09 September 2014 - 12:23 AM

i have 1 very big question to ask. ok i am only 15 and been so into programming since i was 12 and i know this is what i love. but i am not a very good at teaching my self through books or video but i have tryed so hard and  i have learned so much but it never seems like i know enough. like i am always going to be a beginner. so should i just give up and wait till i go to college for game dev and learn there or keep going on like a snail and learning really slowly and feeling like i know nothing all the time?


I've been programming for 20 years now, i still learn new things almost every day and there is a metric crapton of stuff that i still don't know.

Keep your projects small and try to add a few challenges to each project you make, if you havn't made any graphical games yet i'd recommend starting by making a pong clone (it covers the basics without complicating things).

You may allready know enough to solve some problems and you will never know enough to solve all problems, as long as you keep moving forward you will eventually get to a point where you know enough for someone to pay you to write code (and when it comes to learning nothing beats working 40+ hours / week with other professionals)


#5178163 GDI+ support on linux

Posted by SimonForsman on 04 September 2014 - 03:41 PM

As far as I know GDI+ is a Windows-only API, anyway I've read around that one might write his code in GDI+ and be able to port it to linux with something like this:
 
Is this true? Does anyone have experience of GDI+ applications that can also run on linux?


https://www.winehq.org/docs/winelib-guide/winelib-introduction

Yes it is sort of true, if your windows binary will run with wine then your windows source code will most likely compile using winelib aswell (Making porting quite a bit easier)


#5177118 unity monthly subscription question?

Posted by SimonForsman on 30 August 2014 - 03:45 PM

I have really not looked at Unity much, but the questions that come to my mind are:

  • Can the free version be used for commercial purposes?
  • If not 1., can existing unreleased closed source code be legally transferred to the commercial pro-version later?
  • Is there a free version for Android and iOS?
  • How much effort is needed to port between platforms? I know the "native" platform languages and API's are different, but I understand Unity abstracts all of that nearly entirely.
  • Assuming 4. is somewhat less than "you really need to be working on all platforms from the very begining", why can you not just develop on Windows on the Free or Pro version until pretty late in development (you have a mobile like OS in Windows 8 if you need that), then get the extra mobile licenses later?
  • can you not pick either iOS or Android, and only if you have a successful project consider porting to the other?
  • If either 1. or 2., is there actually any feature in the Pro version you really need thats worth that investment?
  • If 7. and 3., why would you ever need to get the pro version?
It certainly seems to me like you should be able to proceed by paying nothing now, later maybe getting just the core pro version, sometime later getting one mobile addon, and only getting the second mobile addon after you start having some income.


1) Yes you can use it commercially, there is however a limit on your annual turnover (If you had a turnover above $100k the previous fiscal year you're not allowed to use the free version)

2) Yes you can transfer your code and work to the pro version whenever you want.

3) Yes, Android, iOS and Windows phone support is included in the free version

4) It depends, for a simple game there is not much effort at all required (As unity takes care of it and it is unlikely that you'll run into hardware limitations), If you need to use platform specific functionality or adapt your user interface / controls / etc to the platform there will be a bit of work required though and for more advanced mobile projects you will have to test things properly on a wide variety of hardware.

5) You could do that, Windows phone(and blackberry) support is included in the normal free and pro licenses (iOS and Android is only included in the free version, they cost extra in the pro version), you won't be able to test your game on iOS and Android without buying the extra licenses though so if you plan on releasing on both iOS and Android you will save time(and thus money if you are paying professionals to work for you) by getting both licenses from the start.

6) That is an option.

7) There are a whole bunch of features such as dynamic soft shadows, hdr, 3d textures, render-to-texture(required for a huge number of advanced shader effects), IK-rigs and productivity boosting functionality (scriptable asset pipeline, profiling tools, etc) that are cut out from the free version, so if you: A) need some of the cut features to make your game or B) value your own or your employees productivity (Which you would do if you're a professional as time = money) then you should get pro licenses.

8) Even if you don't need or want any of the pro-only features the free version can't be used by any business which had a annual turnover of more than $100k the previous fiscal year (Which basically means that it can only be used by start-ups, hobbyists and some really small and not very profitable companies).


#5176738 Include file not found in GCC, due to path size?

Posted by SimonForsman on 28 August 2014 - 01:42 PM

You should probably use *nix style paths instead for a cross platform title (/ instead of \)




PARTNERS