GPWiki.org
GPWiki.org
It is currently Wed Jun 19, 2013 3:50 pm

All times are UTC




Post new topic Reply to topic  [ 46 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: What to do next?
PostPosted: Tue Aug 30, 2011 12:34 pm 
King Code Monkey
User avatar

Joined: Wed Sep 01, 2004 3:05 pm
Posts: 11199
Location: Abingdon, MD
theraje wrote:
There's also this thing called a forum... you ask questions and discuss things

There's a difference between asking questions about specific problems and asking questions that are covered in one or more chapters in a book. The question above is of the latter variety. Expecting a useful answer in a forum post about something that pages dozens of pages to go over is kinda silly. Yes, you answered his question, but how useful was it really? Did your answer give him the ability to go off and start using sprite sheets? Probably not, so was your post worth making?

Maybe it's just because I see dozens of these kinds of posts every day and the laziness of people these days pisses me off. Usually the next post in this kind of discussion is "Can you give me some source code to do this?" :x :(

_________________
Bored? Head on over to my blog and see what I'm up to.

Microsoft XNA MVP


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Tue Aug 30, 2011 4:07 pm 
Dexterous Droid
User avatar

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3746
Location: South Africa
I'm inclined to side with Machaira. If you're going to post a question on a forum, please show evidence of having looked for the answer elsewhere first. Explain as much as you know about the background of your question. Even if you have looked for information first but don't mention any of your prior research, it looks lazy for everyone else who is meant to help you.

Hope I don't sound too gruff. :)

_________________
Whatever the mind can conceive and believe, it can achieve


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Tue Aug 30, 2011 5:44 pm 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3854
Location: Ferriday, LA, US
Machaira wrote:
Did your answer give him the ability to go off and start using sprite sheets? Probably not, so was your post worth making?


Maybe my post didn't give him any specifics, or working code, but really -- was your "RTFM" post any more helpful?

Machaira wrote:
Maybe it's just because I see dozens of these kinds of posts every day and the laziness of people these days pisses me off. Usually the next post in this kind of discussion is "Can you give me some source code to do this?" :x :(


Well, is it too much to give the person the benefit of the doubt until they ask for such a thing?

The forum rules talk about things like erring on the side of friendliness. I know I'm not a shining example of friendliness most of the time, but yeesh...

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Tue Aug 30, 2011 6:11 pm 
King Code Monkey
User avatar

Joined: Wed Sep 01, 2004 3:05 pm
Posts: 11199
Location: Abingdon, MD
I'm all about the tough love. 8) A person learns nothing by being spoon-fed.

I'm happy to answer specific questions.

_________________
Bored? Head on over to my blog and see what I'm up to.

Microsoft XNA MVP


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Tue Aug 30, 2011 6:37 pm 
Shake'n'Baker
User avatar

Joined: Mon Jun 14, 2010 3:51 pm
Posts: 62
Machaira wrote:
"Can you give me some source code to do this?"

I never ask 4 source codes, I only ask about the algorithms.

But I must say...that spritesheet thing was my fault. I should have asked a more specific question that wasnt answered elsewhere. Sorry.

so my question about spritesheets version 2 is:
In Metal Assault, a 2d MMO side-scrolling game, there's a bunch of outfits, armors, weapons. Do they have a ton of spritesheets? Or is there a trick to do it? (Just wanna know)


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Tue Aug 30, 2011 7:17 pm 
King Code Monkey
User avatar

Joined: Wed Sep 01, 2004 3:05 pm
Posts: 11199
Location: Abingdon, MD
Quack wrote:
I never ask 4 source codes, I only ask about the algorithms.

I know. I said that in my experience, general questions are usually followed by a request for source.

Machaira wrote:
Do they have a ton of spritesheets?

Probably a bunch. It's a much used technique.

_________________
Bored? Head on over to my blog and see what I'm up to.

Microsoft XNA MVP


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Tue Aug 30, 2011 8:08 pm 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3854
Location: Ferriday, LA, US
Quack wrote:
In Metal Assault, a 2d MMO side-scrolling game, there's a bunch of outfits, armors, weapons. Do they have a ton of spritesheets? Or is there a trick to do it? (Just wanna know)


Never played it, but most likely there are sprite sheets for every type of outfit/armor/etc., and they are overlaid on top of the sprite image. This way, you can have characters with different skin colors, different outfit configurations, etc. without needing to make each combination in images. Think of it as a "dress-up" game. :P

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Tue Aug 30, 2011 8:11 pm 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3854
Location: Ferriday, LA, US
Machaira wrote:
I'm all about the tough love. 8) A person learns nothing by being spoon-fed.


I agree, but I still don't see the point of insulting someone, when it would work much better to just point them in the right direction.

Anyway, I'll get off the subject... this thread is already plenty derailed. :P

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Wed Aug 31, 2011 8:00 pm 
Dexterous Droid
User avatar

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3746
Location: South Africa
theraje wrote:
Quack wrote:
In Metal Assault, a 2d MMO side-scrolling game, there's a bunch of outfits, armors, weapons. Do they have a ton of spritesheets? Or is there a trick to do it? (Just wanna know)


Never played it, but most likely there are sprite sheets for every type of outfit/armor/etc., and they are overlaid on top of the sprite image. This way, you can have characters with different skin colors, different outfit configurations, etc. without needing to make each combination in images. Think of it as a "dress-up" game. :P


Yeah this is how it usually goes down. This is best example I could find of a sprite sheet with separate pieces for hair, weapon, clothing, etc.
Image

_________________
Whatever the mind can conceive and believe, it can achieve


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Fri Sep 02, 2011 1:58 pm 
Shake'n'Baker
User avatar

Joined: Mon Jun 14, 2010 3:51 pm
Posts: 62
Thnx. I am having a problem with the fps timing and sprite changing.

In 10 fps how many times should I change the sprite to give the illusion of motion?

and I think I will code the gameLoop function later after I get the other technical stuff right so can you pros tell how to make it work in every scenario? Or maybe I am taking a bad step here. Maybe I should think small now.


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Fri Sep 02, 2011 2:09 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6752
Location: Oxford, Englandshire
It depends on the range of movement. It's generally accepted that 16fps is enough for most animation to appear as smooth movement. (http://en.wikipedia.org/wiki/Persistence_of_vision) However, you can get away with less for small movements.

Consistent motion is probably more important, using time based modelling rather than frame timing adds complexity, but provides a better result.

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Fri Sep 02, 2011 3:25 pm 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3854
Location: Ferriday, LA, US
Quack wrote:
In 10 fps how many times should I change the sprite to give the illusion of motion?


As Codehead suggests, this is not something that has a hard-and-fast "correct" answer... it depends on many factors -- the complexity of the animation, the number of frames, and so on. Then it still takes a subjective eye to find the motion that "feels" right.

Quack wrote:
and I think I will code the gameLoop function later after I get the other technical stuff right so can you pros tell how to make it work in every scenario? Or maybe I am taking a bad step here. Maybe I should think small now.


The game loop is pretty much the first thing I always work on -- in fact, it was the first feature I coded for my JavaScript game library (which I plan to release soon). The game loop is one of those parts of a real-time game that is pivotal, and should not wait, IMO.

To make it work in "every scenario" is pretty simple. The main idea is to separate the game loop from the game logic-state, and have the game loop control the logic-state. Also, you will want to measure the time between updates, and feed that to your logic-state so that it can "adjust" itself according to how much time has passed.

Let's say your logic-state has a function update(elapsedTime), which moves a sprite according to time. You would do something like this:

Code:
sprite.X += sprite.speed * elapsedTime;


For example, of course -- you would do things like collision handling in your own code, but that gives you an idea how it works.

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Sat Sep 03, 2011 2:47 pm 
Shake'n'Baker
User avatar

Joined: Mon Jun 14, 2010 3:51 pm
Posts: 62
thnx.

theraje wrote:
my JavaScript game library (which I plan to release soon)

Looking forward to it! Maybe I would dump my project and use your framework. :thumbs

BTW what's the difference between a game engine and a game framework/library? I am confused.


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Sat Sep 03, 2011 3:05 pm 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3854
Location: Ferriday, LA, US
Quack wrote:
BTW what's the difference between a game engine and a game framework/library? I am confused.


The differences between them are a bit fuzzy, but a game engine has more functionality geared to a specific game/genre, while a framework or library has more generalized game-related functionality.

Quack wrote:
Maybe I would dump my project and use your framework.


I'll post something on the forum (maybe in the Announcements section) once I have something available to download. I mainly am working on it because I got tired of writing the same/similar code for different projects, as well as having bits and pieces of that code in separate scripts. I already have the game loop/logic, rendering, input, assets management, and audio parts done, but I still need to add a couple more features (mainly related to images) before it will be released.

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Sat Sep 03, 2011 6:49 pm 
Shake'n'Baker
User avatar

Joined: Mon Jun 14, 2010 3:51 pm
Posts: 62
theraje wrote:
I'll post something on the forum (maybe in the Announcements section) once I have something available to download

Then I will keep an eye on it.

I am trying to keep mine simple. But I have rewritten my code twice all over again, even though each renewal was faster than the last. I think it's becoz I didn't sit down n plan my game engine. Either way, html5/javascript coding is addictive.


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Wed Sep 07, 2011 4:42 pm 
Shake'n'Baker
User avatar

Joined: Mon Jun 14, 2010 3:51 pm
Posts: 62
Me: Need help.....
You: again!! COME ON!!

I was looking at other game engines one of them is http://love2d.org/wiki/love.timer, and the thing that my project needs is the timer class. I read the documentation of those engines. But I can't seem to grasp the concept. And can't answer this questions I keep coming up with:

- Why do I need all those properties?
- What methods would use them?
- How would this class make life (game coding) easier?

They are pretty much the same question.....


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Wed Sep 07, 2011 6:34 pm 
Dexterous Droid
User avatar

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3746
Location: South Africa
You need a timer to do plenty of things in a game. Most importantly, to keep your program running the same across all different types of hardware. If someone is running the game on a better rig, the game's logic should still run at the same pace and the animations should run at the same pace.

To achieve this, the best way is to separate out your drawing code from your game logic code. Decide on a number of "game" fps you want, like 100, and then keep the game logic running at that rate. The draw code should run without modifying the game state in any way.

Code:
float gametime = 0.0;
const float tickLength = 0.01;
while (running){
   // Run as many game frames according to how much time has passed
   gametime += GetFrameTime();
   if (gametime > 0.5) gametime = 0.5; //Put a cap incase of alt-tab or other lock-up (e.g. debug)
   while (gametime > 0){
      gametime -= tickLength; //The ticklength is how long a "game" frame is. 0.01s = 100 "game" FPS
      update(); //Run the game logic
   }
   // Render the frame once all updating is complete
   draw();
}

_________________
Whatever the mind can conceive and believe, it can achieve


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Wed Sep 07, 2011 8:00 pm 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3854
Location: Ferriday, LA, US
Here's a more JavaScript-friendly game timer --

Code:
function cycleFunction() {
   // exit function if not running
   if (running == false) return;

   // get the current time, determine how much time has passed
   // since last game cycle
   var currTime = new Date().getTime();
   var elapsedTime = currTime - lastCycleTime;

   // update based on time, but no more than a half-second (500ms)
   update(Math.min(elapsedTime, 500)); // in case of extreme lag/pause

   // don't run another cycle until a certain time has passed
   var cycleDelay = desiredFramerate; // for example, 1000/30 == 30 frames/sec
   if (elapsedTime > cycleDelay) {
      cycleDelay = Math.max(1, cycleDelay - (elapsedTime - cycleDelay));
   }

   // save the current time for the next cycle
   lastCycleTime = currTime;

   // call the cycle function again, after a delay
   setTimeout(cycleFunction, cycleDelay);
}


You'll need to have an update(elapsedTime) function that handles your logic's input/AI/drawing/etc., but other than that this function is pretty complete. (I pulled this from my library... if anyone has any suggestions or "gotchas" to make it any tighter, let me know!)

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Thu Sep 08, 2011 10:52 am 
Shake'n'Baker
User avatar

Joined: Mon Jun 14, 2010 3:51 pm
Posts: 62
Algorithm would have been just fine. Now Machaira got something to tease me :doh
But I do appreciate the code. Thanks :thumbs

IGTHORN wrote:
Code:
   if (gametime > 0.5) gametime = 0.5; //Put a cap incase of alt-tab or other lock-up (e.g. debug)

Got it. But I got some questions...why limit the game time to 0.5? Shouldn't we reset the game time once in a while?

theraje wrote:
I pulled this from my library... if anyone has any suggestions or "gotchas" to make it any tighter, let me know!

Appreciate the javascript syntax, one thing...it seems to have more of a function structure than a class, so how do I get access to the privates variables? Don't I need them for calculation?

I see, basically you use the game time together with some logic to update state/data and animate.
So I can just add this algorithm to the game loop. And I thought I had to write another class.


Top
 Profile  
 
 Post subject: Re: What to do next?
PostPosted: Thu Sep 08, 2011 2:39 pm 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3854
Location: Ferriday, LA, US
Quack wrote:
it seems to have more of a function structure than a class, so how do I get access to the privates variables? Don't I need them for calculation?

The code I pasted here is slightly modified, but the only thing you need to do with the function in its current state is define an update(elapsedTime) function that does your drawing/input and other stuff, and a desiredFramerate variable. The desiredFramerate variable is 1000 divided by how many frames per second you want.

Oh, and I suppose having a variable called 'running' and setting it to a non-false value would help. :P Almost forgot about that one. Once you have all that set up, just make one call to cycleFunction(), and the rest handles itself.

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 46 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group