Jump to content

  • Log In with Google      Sign In   
  • Create Account

SimonForsman

Member Since 18 Oct 2005
Offline Last Active Today, 08:13 AM

#5203650 how make games in c++

Posted by on 12 January 2015 - 05:26 AM

yes I programmed Hello World

 

but how make games in c++

 

book tutorial serves

 

C++ does not have any functionality for rendering graphics in its standard library, you will need to use whatever APIs your target platform provide (or a higher level cross platform library such as SDL or SFML) for that.

 

At the most basic level a game consist of a loop that:

1. checks for user input.

2. Updates the game state

3. Draws a representation of the game state to the screen.

 

I'd recommend taking a look at SDL or SFML (both work on all major desktop operating systems and are reasonably easy to use)




#5203267 Adding third party libraries to version control

Posted by on 10 January 2015 - 08:18 AM

When the repository of your submodule gets moved by its owners, suddenly all your commits get broken. Even when you add a new commit to fix it it does not repair your older commits and you can have fun with learning git filter-branch, if you even feel retroactive editing on old commits is appropriate.

I read it may help to have a simple high level repository only storing submodule commit ids and treat your code like all libraries by keeping it in a submodule, but this adds busywork the whole time you use it.

 

The easy solution is to clone the library repository and maintain your own, just keep the official repo as a remote to pull updates from (its easy to change a remote if it moves)




#5201868 Lowest android device to target?

Posted by on 05 January 2015 - 01:02 AM

Where are these dashboard figures?

you linked to them in your first post.




#5201717 Is it possible to overwrite apps on Android when developing?

Posted by on 04 January 2015 - 05:55 AM

When developing an app for android and testing it on my device always get an error message when I try to install my game if I already have a version of it on the device. So I always have to first uninstall the app, and then install the new one. This is very tedious when you are in rapid developing and testing a lot. It would be so much smoother if you could just install the new version and have it overwrite the old one. Is this possible somehow? Maybe some setting that can change this?

 

Activate developer mode and USB debugging on your phone, don't manually install the app(just run it from your IDE) and it will overwrite properly each time, alternatively you can just raise the version number before each deployment (you don't need to uninstall before installing a newer version)




#5201235 making a serious game in flash

Posted by on 02 January 2015 - 01:34 AM

The Binding of Isaac was a pretty big game made in Flash with ActionScript 2, and you can read a postmortem on Gamasutra.

 

On page 3 and page 4 there's a sections entitled "Performance and Feature Issues with ActionScript 2" and "Too Big in Scope for Flash" that are pretty relevant to your question.

 

 

Hope that's helpful! smile.png

 

It might be worth mentioning that AS3 is significantly faster than AS2 (JIT compilation was added with AS3 and the difference is massive (AS2 was quite awful, even things like the length of your function/variable names had a measurable performance impact), most of the fla/swf size issues can be worked around by splitting things up and loading them at runtime, AS3 also added the GameInput classes (for dealing with gamepads, joysticks, etc) and a whole bunch of other nice features, a pre-made native extension for steamworks exist on github (fresteamworks), There are still issues with Flash (such as awful/non-existant support outside of Windows and OS X for example) but i wouldn't dismiss it based on a postmortem for a game that was made using an ancient version of the platform.




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

Posted by 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 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 (Linked lists have horrible cache performance and are almost always the wrong choice) (edited for clarification)

 

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 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 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 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 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 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 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 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 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.






PARTNERS