Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / After some advice on game design

Author
Message
Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 22nd Jun 2007 03:47
Hi All, I'm making a space trading/fighting game and its begining to take shape but I've been a bit gun-ho with regard to planning - always been a fault of mine - LOL. I guess I was in a hurry to learn how to do things first but now is a good time to rethink and reorganise the code in light of any advice received from my points below.

1. I'm using a lot of variables (some of which could be more efficiently employed). Has anyone noticed significant slow down or drop in FPS from the computer having to store lots of names and numbers (the variables themselves are largely numeric or single word $, not huge big strings)

2. My 3D Ship models, created from DOGA L3 (great program btw), involve overlapping various pre-defined shapes (e.g. sticking a wing piece onto the main body). However, in doing this, sometimes bits of the wing are overlapped internally into the ship. Not a problem from a visual perspective as you can't see this but I am concerned that DB is still having to remember the overlapping bits when the engine renders the models and this might cause slow down. Does anyone have any advice/comments on this?

3. Does the actual size of the program matter in terms of speed (FPS). What I mean is this - best explained by example. Consider the following very simple program...

Gosub PrintText

PrintText:
While Spacekey()=0
For i = 1 to 50
Text 0,i*20,ShipData$(i) : Rem pretend ShipData$(50) exists
Next i
sync
Endwhile
Return

Now consider that this subroutine is called within a much larger program (20,000 lines of code for eg). Will the speed of the routine drop significantly simply because of all the other 19990 lines of code. If I've hidden all 3D models (hide obj 1-200), cleared the screen then I cant see how unless the memory required to remember all variable names at this point slows it down.

4. I find it a bit annoying there isnt a "min" and "max" command. E.g. I have to type:

Money = Money - Trade
if Money < 0 then Money = 0

Isnt there a command like...

Money = Max(Money-Trade,0)?

5. I'm finding my ship models look a bit twitchy when they are at a distance (sort of a flickering effect as they rotate and turn etc). Any ideas on how to improve this?

Thanks in advance for any help on these.
Sinani201
19
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 22nd Jun 2007 19:02
Quote: "I'm using a lot of variables (some of which could be more efficiently employed). Has anyone noticed significant slow down or drop in FPS from the computer having to store lots of names and numbers (the variables themselves are largely numeric or single word $, not huge big strings)"


Do you have a specific group of variables?

If you have large groups of related variables, always use the DIM command to put them together
so instead of:



You could do...



It may involve a little bit more typing, but it makes things much easier and organized. If you use large amounts of related variables you would have to check through each line until you find the right one, which would involve a lot of typing.
This code right here wouldn't work:



because playertspeed was never a variable!! t is its own variable, and values cannot be included in variable names. (Sorry if that's a little confusing). In other words, variable names is ONLY what you name it, and what is inside of the name.
So instead, you could do this:



And because the parentheses expect a value, and 't' is a value, it will recognize that. That doesn't invovle to much typing, right?

Thank you for taking the time to read this,
Sinani201

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
Sinani201
19
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 22nd Jun 2007 19:07 Edited at: 22nd Jun 2007 19:09
Quote: "I find it a bit annoying there isnt a "min" and "max" command. E.g. I have to type:

Money = Money - Trade
if Money < 0 then Money = 0

Isnt there a command like...

Money = Max(Money-Trade,0)?"


I need more info. What is the max? What's the 0 in
? I could write up a simple code if you can answer those two questions.

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
Sinani201
19
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 22nd Jun 2007 19:13
Quote: "
2. My 3D Ship models, created from DOGA L3 (great program btw), involve overlapping various pre-defined shapes (e.g. sticking a wing piece onto the main body). However, in doing this, sometimes bits of the wing are overlapped internally into the ship. Not a problem from a visual perspective as you can't see this but I am concerned that DB is still having to remember the overlapping bits when the engine renders the models and this might cause slow down. Does anyone have any advice/comments on this?"

Why not just use any other 3D modeling program (like Anim8or, which I think is the best), and make the wings and the airplane body all in one object?

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
Sinani201
19
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 22nd Jun 2007 19:22 Edited at: 22nd Jun 2007 19:36
Quote: "3. Does the actual size of the program matter in terms of speed (FPS). What I mean is this - best explained by example. Consider the following very simple program...

Gosub PrintText

PrintText:
While Spacekey()=0
For i = 1 to 50
Text 0,i*20,ShipData$(i) : Rem pretend ShipData$(50) exists
Next i
sync
Endwhile
Return

Now consider that this subroutine is called within a much larger program (20,000 lines of code for eg). Will the speed of the routine drop significantly simply because of all the other 19990 lines of code. If I've hidden all 3D models (hide obj 1-200), cleared the screen then I cant see how unless the memory required to remember all variable names at this point slows it down."


Even if you hid the 3D objects, they are still in memory because you could always show them again! if you delete the object it will definitely free up memory because you can't do anything to bring it back, except creating it again. And of course it would slow down the program because it does have to remember all of the info. But remember what I said about the DIM command? Not only does it keep the program more organized, it also frees up memory from variables. playerscore(1) and playerscore(2) act as one variable because they were generated with the DIM command. One DIM is worth one variable, unless you use more than one dimension. Each dimension is worth one variable.

That used two dimensions because of the comma separating 2 variables.

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
Sinani201
19
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 22nd Jun 2007 19:24
Quote: "I'm finding my ship models look a bit twitchy when they are at a distance (sort of a flickering effect as they rotate and turn etc). Any ideas on how to improve this?"

That happens to me, unfortunately I don't know how to fix this, sorry.

Did someone say 3D scanning on my desk, or was that just an AdBot?
What happens when when you mix coke, pop rocks, vinegar, and baking soda?
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 22nd Jun 2007 20:57 Edited at: 22nd Jun 2007 20:59
Min & Max are functions in my first function collection (attached).

Quote: "5. I'm finding my ship models look a bit twitchy when they are at a distance"


Scale your world down - you probably have everything too big.

TDK_Man

Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 25th Jun 2007 01:45
Thanks Sinani201 and TDK for your help. I will look at your functions TDK and investigate anim8or. Pity I've already designed 50 ships using Doga L3 but oh well, I suppose I knew when I started programing again that much time would lost going up blind alleys

I am in fact using mostly DIMs for that reason (and also for ease) but was later told that the space taken up from using Score1 = Y: Score2 = Y or Score(1) = X : Score(2) = Y is the same because the computer records DIM variables as separate variables anyway.

Very interesting point regarding the hide object command. I thought when you hide an object it would take up less processing time because it doesnt have to render the graphics each loop. Sure it will take up some time because as you say, it will need to remember there is an object there but didnt think it would take up the same time. Please correct me if I have misunderstood you on this. This is really important to me as it will shape the way I organise all my NPCs in the game.

Thanks again guys. Really appreciate it when people take the time to help others
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 25th Jun 2007 08:13
Quote: "Very interesting point regarding the hide object command. I thought when you hide an object it would take up less processing time because it doesnt have to render the graphics each loop"


Hiding the object will improve processing time because the processor does not have to render the object.

And yes, it will exist in memory even if it is hidden. This can affect performance but only when the memory use is tight. If the processor has to deallocate and reallocate several chunks of memory to try and squeeze as much free memory out of your machine, then you'll notice a performance hit - bascially as you run out of memory, the machine will slow down because it has to figure out ways to manage dwindeling resources - not likely to happen unless you have very little memory to start with, or you have huge amounts of objects and/or media. If the object is being displayed, it of course uses more memory than it does being hidden and if it's displayed, the processor has to perform all the necessary math and fire off the correct pixels etc.

So in short, hiding objects improves performance. If you take managing object resources a step further, only create the objects at the point that they are necessary, and remove any that won't be needed. Do not however, constantly create and delete the same objects in succession over and over, because deleting and creating an object over and over takes more processing time than hiding and displaying the object. If you won't be using some obejcts for a while, delete them. And don't create them until you actually need them.

Quote: "it will need to remember there is an object there but didnt think it would take up the same time"


Unless you actually reference the hidden object, the processor doesn't have to deal with it. In DirectX, the objects are stored in memory and referenced by an address held in a pointer - which is really just a variable. If you don't call the pointer with some object command in DB, the object will still be sitting in memory, but the processor doesn't have to do anything. Once you reference that object, then the processor has to do something with it.

Note the screen fps change in the following example that displays or hides 200 spheres.



Enjoy your day.
Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 25th Jun 2007 08:44
Thanks Latch! Thats good, I think then I should be ok with just hiding objects but if I run into problems I will try the delete/create approach.
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 29th Jun 2007 22:30 Edited at: 29th Jun 2007 22:35
@ Hangar18

Hey I like your game idea. I'm guessing there's gonna be loads of planets in the game, so a good way to manage the memory is to only show the ones that are nearest your ship (or whatever the player is), and hide planets as they go out of view (is that what you meant Latch?). Then when they're really far away, delete them.
Here's another idea I had but I'm not sure if it will save memory: You could create 2d images of all your planets, then when your ship gets far away, delete the 3d planet and replace it with a 2d plain. I think that way you could have many more planets on screen at once and still save memory.
Am I right guys?

Login to post a reply

Server time is: 2026-07-05 22:05:35
Your offset time is: 2026-07-05 22:05:35