Jump to content

  • Log In with Google      Sign In   
  • Create Account


Servant of the Lord

Member Since 24 Sep 2005
Online Last Active Today, 07:57 PM
*****

#5028937 Games Development Beginnner

Posted by Servant of the Lord on 04 February 2013 - 11:41 PM

Getting started in game development is design and most specifically the design document.

Game development != game design. smile.png 
(Game design is a field within game development, but game development contains a dozen or more fields, most of which can be broken down further)

Not everyone wanting to be a 'game developer' wants to be the designer.
The OP specifically mentioned programming languages, saying "I want mainly be a programmer".




#5028924 Drawing map takes all CPU

Posted by Servant of the Lord on 04 February 2013 - 10:58 PM

SDL_Surface has built in ability to "draw" just portions of a larger image (like your tilesheet).

By not creating entirely new surfaces, you'll automatically gain enormous speedups (The fastest code is the code that never runs).

See Lesson 6, of Lazyfoo's SDL tutorials for a demonstration.

 

Not everything needs to be wrapped in classes - sometimes in an attempt to be "object oriented", we tend to over-use classes in our code and accidentally discard the other types of programming architectures or, like in this case, eliminate important functionality that used to exist before we wrapped the libraries.

 

SDL_Surface is perfectly good as it is, without being wrapped. wink.png

 

Not all OOP objects need to be C++-style classes, and not all code needs to be OOP.

If you are trying to code in OOP,  I'd recommend not worrying about it, and instead focusing on the RAII, KISS, DRY, and SRP principles.

If you don't know what OOP is, or why I keep on yacking on about it, just focus on those last four links instead and forget I ever mentioned OOP.




#5028918 Translating high fantasy RPG/roguelike concepts into futuristic setting

Posted by Servant of the Lord on 04 February 2013 - 10:35 PM

  • Treasure (chests) : Computers with datacaches that can contain ingame info, plot background, or downloadable 'patches' and 'mods' for your digital weaponry?
  • Deities and worship : Replace 'deities' with charismatic CEOs, 'worship' with Apple fanboys, and organized religion with corporations? The effects are better biomods for those closer to the CEO.
  • A relatively small population : Gene plagues, ftw.
  • medieval social structure : The "fuedal system: serve the local baron, he owns all the land you live on" is replaced by the "corporate system: employed by the local corporation CEO."
Your bolt weapons sound like they'd kill or incapacitate in one hit. Then again, arrows do that as well, in real life, but not in games. Well, swords would kill or incapacitate in one hit IRL also - but games have conditioned us to 'twenty sword blows or thirty arrows to kill', but have also conditioned us to '3 gun shots to kill'. With current videogame conditioning, you'll have to fight against the immersion-break that a railgun won't just kill someone in one hit.


#5028900 Drawing map takes all CPU

Posted by Servant of the Lord on 04 February 2013 - 08:54 PM

Do you actually notice it lagging, or are you assuming it's lagging because your CPU usage is 100%? 

Are you actually measuring the milliseconds per frame (and not FPS)? smile.png

 

If your CPU is at 100%, that's because your program is basically saying, "Run as fast as you can, and we'll loop around and around the main loop until we decide to stop". If it's using 100%, it's because nothing else is currently using the processing power so the CPU just shrugs and runs your code faster.

 

The cheap and easy way to drop your CPU usage less than 100% is to just add a SDL_Delay(0) to the end of your main loop. It's not the best solution, but it'll suffice for a smaller project.

 

If your program is lagging, it's probably because you are calling 'new' every iteration of your two for() loops. 'new' can be expensive. If you just had one 'Sprite' created on the stack (not new'd, and not a pointer) and re-used it for every iteration, it'd go faster.

However, worse than that, is that you are using new wrong! Lesson one of using 'new' is the absolute rule: For every 'new' you must absolutely have a 'delete'*. You really shouldn't be using 'new' at all in this situation, but even if you are, you absolutely must learn how to use new before you actually use it. 'new' is not one of those things that you learn by using, it's something that must be learned firmly before using.

 

*And for every new[] a delete[], and for every malloc() a free(), and so on...




#5028692 Any information about new consoles (high end) - just out or pending ?

Posted by Servant of the Lord on 04 February 2013 - 11:05 AM

Nintendo WiiU is fully out, and all the information is available for it.

 

Sony is releasing information about the next Playstation on the 20th of this month. They probably will focus more on console features, launch games, and the console/controller appearance, and gradually release the technical details in the month following that. Or, if it's super impressive, they will just release it all in one blow as a surprise.

 

The next XBox won't have any information released until E3 probably (which is June), but Microsoft may bump up their revelations sooner because of Sony's earlier-than-expected announcements.

 

It probably won't be until the end of 2013 that you will get the exact details you want, when the PS4 is already released and the XBox Next is already released or about to be.




#5028685 Music Costs

Posted by Servant of the Lord on 04 February 2013 - 10:54 AM

I had a guy who was working with me until I asked him to sign an NDA. ( the work he was doing needed to be protected by one ) I pulled a standard NDA from the internet and modified some names and titles as well as ensuring it was for non payment ( since none of us are being paid right now ) and he wouldn't sign it.

 

Happened with me once. A hobbyist composer was making music for me, but when I asked for him to sign a contract, he was very hesitant. Full understandable, because from the average Joe's perspective, they think they can get burned signing contracts just as much as the buyer could get burned by not having them sign one. Contracts are associated with lawyers and lawsuits and banks and debt, whereas a hobbyist is in it for fun or to help you out and suddenly you're taking the fun out of the situation and making the project seem financially dangerous to them when previously they viewed it simply an innocent hobby they were doing in their spare time.




#5028532 What is the difference between "Entity" and "Sprite"?

Posted by Servant of the Lord on 03 February 2013 - 10:07 PM

A "sprite" is a 2d image. Some game engines might have a sprite-entity, which is a thing that can be drawn using a picture.

 

But, as mentioned, it depends. Some games don't consider 2D tiles to be 'sprites', but will consider character and NPC animations to be composed of sprites. A GUI button might not be considered a sprite, but the particle effect image for a fireball might be. So it really is vague and varies from game engine to game engine.




#5028159 Timing seconds per frame in C++

Posted by Servant of the Lord on 02 February 2013 - 02:26 PM

You don't measure in seconds per frame, because one frame is less than a second. Usually you measure in millaseconds per frame or microseconds per frame.

 

Here's the code I use: (it's cross-platform, with millisecond accuracy)

#include <ctime>
 
//The time, in seconds, since the program started. (1.5f = one and a half seconds)
Seconds RunTimeInSeconds()
{
    //CPU "ticks" since the program started.
    clock_t programTickCount = clock();
 
    //Convert from ticks to seconds.
    float seconds = float(programTickCount) / CLOCKS_PER_SEC;
 
    return seconds;
}
 
//Same as above, but in millaseconds as an integer. (1500 = one and a half seconds)
Milliseconds RunTime()
{
    //CPU "ticks" since the program started.
    clock_t programTickCount = clock();
 
    //Conversion rate between ticks and millaseconds.
    float msMultiplyer = 1000.0f / CLOCKS_PER_SEC;
 
    //Convert from ticks to seconds.
    int millaSeconds = (programTickCount * msMultiplyer);
 
    return millaSeconds;
}

 
Using microseconds gives even more accuracy, however there are not any standard microsecond timers in C++, so you have to use third party or OS-specific timers, unless you are using the new C++11 standard's <chrono> library, which has a high precision timer that might be microsecond or better, but falls back to milliseconds if microsecond precision isn't available.




#5028043 Dev Kit question

Posted by Servant of the Lord on 02 February 2013 - 12:23 AM

...I just want to have a 15 minute playable demo. Nothing over the top.

 

Just be aware that "15 minute playable demo" is alot more work than it sounds.

 

You hear "15 minutes" and "demo" and think, "oh, it's like 1/1000th of a game".

No, it's like 1/10000th of the *content* for the game.

It's about 70-80% of the 2-year development of the game, programming-wise.

 

To be "playable", you need the input, physics, AI, graphics, sound, logic, and pretty much everything else working even if buggy. Basically, you need all the parts of the game already functional (even if not perfect). Removing the content helps the artists, not the programmers... the programmers weren't making the art/models/levels/music anyway.




#5027943 Need funcion to return char[]?

Posted by Servant of the Lord on 01 February 2013 - 02:51 PM

As SiCrane is hinting at, with C++ always prefer std::string unless you have a real reason not to.

 
ya I do, like I said above I'm working with some really old code and it'll take too long to convert it all...

 

It'll take too long on the front end, but over the lifetime of the project, you'll probably waste more time fighting the chars.
If you have deadlines though, then there may not be enough time to meet the deadlines and refactor the project. Still, if you could schedule a time (three days or whatever you estimate it'll take) in the near future to refactor that aspect of the project, I think you'll feel alot better about it - and the code will certainly benefit from it.

But that's just my opinion!

Even if you can't use std::strings everywhere, you could still use them as a container-type for char arrays.

std::string cApp::ReturnString(char[30] &Temp)
{
	std::string copy(temp, 30);
	//...
	return copy;
}
 
... later code...
std::string B;
std::string A = DoSomething(B[0], B.size());

(Assuming DoSomething() already exists as part of the old code-base and can't be changed. Otherwise, it'd be much better off just taking a std::string)
 
But everything new you write would be much better off as std::string.
If you absolutely have-to-have-to-have-to, you could do something like this:

struct CharArrayStruct30
{
    char data[30]; //Horrible. *shudders*
};

 
But even this would be a step up:

struct RawStringStruct
{
    char *data;
    size_t size;
};

 
But std::strings constructors and functions are compatible with C-style raw strings, so you can migrate your codebase away slowly if you like.




#5027921 Array of Pointers

Posted by Servant of the Lord on 01 February 2013 - 01:12 PM

Here's a commonly used occurrence of arrays of pointers:
 

int main(int argc, char *argv[]) //'argv' is an array of char pointers.
{
    for(int i = 0; i < argc; i++)
    {
        char *str = argv[i];
        std::cout << "String " << i << ": " << str << std::endl;
    }
    
    return 0;
}

You keep saying an "an array of pointers", and you keep on using an array of pointers syntax. However, your functions look like you are actually wanting a pointer to an array instead of an array of pointers.

In C++ an array is almost identical to a pointer, and you can convert an array to a pointer very easily and implicitly:

int array[] = {0, 1, 2, 3, 4, 5};
int *pointer = array;
 
void myFunc(int *pointer);
myFunc(array);



#5027914 Need funcion to return char[]?

Posted by Servant of the Lord on 01 February 2013 - 12:47 PM

As SiCrane is hinting at, with C++ always prefer std::string unless you have a real reason not to.




#5027678 Global Event Manager System

Posted by Servant of the Lord on 31 January 2013 - 05:55 PM

It is certainly more widely useful in desktop applications which are event-driven. Nothing happens until you click a button or type into the keyboard.
Games are different. It is definitely an error to make a global event system that tries to push your game into a heavily event-driven state. Events in games are better suited for handling script-related events, such as a player walking into a certain area of the map and triggering an in-game cinematic.
There are times and places for event-based systems in games, but outside of this example there are very few.

Event processing is one of the areas I have difficulty implementing neatly. mellow.png

Likely a sign that you intuitively realize that event systems in games are not to be used the same way they are in event-based desktop applications.
Event systems are to be used sparingly in games and only after much planning and pondering.

 
I definitely realize the difference - I use the Qt framework, which handles almost everything through signal-and-slots. I use the signals and slots in my non-game applications, but in my games I do two things: I have gamestates with Update(deltaTime) calls for frame-to-frame changes, and I also have events (like OpenMainMenu or CurrentAreaHasChanged) - the vent part is probably the anti-pattern you are talking about, but I can't really see better big-picture solutions despite being not very pleased with it.
 
Part of my dissatisfaction is the grammatical tense of my events: Some are commands: OpenMainMenu asks/tells the Main Menu to open, while others are messages: CurrentAreaHasChanged lets other systems know that the area has already changed. But they are using the same system, and the whole thing just feels 'off' to me. Right now it's not so bad, since the events are mostly GUI (OpenMainMenu) or input events (MoveForward), but I'm still not completely satisfied with it.
 
I suppose all my 'command' events should be direct function calls, and only the 'message' events should be events... Hmmm. But having something like "OpenMenuButtonWasPressed" as a message just for another class at a higher level to then directly call a function seems to require more boilerplate code with pretty much the same result.
My system is definitely 'abstract' in that one message is completely unrelated to another. It's 'global' in the sense that any active gamestates receive the messages ("virtual React(message)") and can send messages (thisGameState->GameStructure.SendMessage(message)) but it's not 'global' in the sense of a global variable.
 

I don't have my thoughts straight on this issue, and definitely appreciate any insight you can give. I've previously read several of the entries on your journal, including this one.




#5027637 I dont know were to start AT ALL

Posted by Servant of the Lord on 31 January 2013 - 03:40 PM

This video (by PA TV's Extra Credits) may give you a good outline of what you'll need.

 

The short answer is: it's a lot of work, but anything worth doing is. smile.png

 

Which video? 




#5027615 SFML - Screen Scrolling

Posted by Servant of the Lord on 31 January 2013 - 01:26 PM

Whatever algorithms you use have no bearing on your camera. All that matters is: A) Where in the world your objects are, and B) What portion of the world is visible. From that you calculate where on the screen the objects need to show up in.

 

As for sf::View, here's a tutorial on it.






PARTNERS