3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1] 2

Author Topic: Just 1 TextPrint instead of several ValuePrints  (Read 3042 times)

« on: September 24, 2010, 11:52:04 AM »
As the size of a game in 3D Rad grows and getting overloaded with lots of objects, we think more and more of reducing the loading time.I noticed some tips in the forum and now I too want to give a tip.

If you use some ValuePrint objects in your game and you can place them one close to another you can replace these ValuePrints with just one TextPrint. Of course, it takes some lines of scripting.

Code: [Select]
float timeleft=1200;
//OBJ_0 is the TextPrint we use istead of ValuePrints
void Main()
{
string sp,ang,left;

float speed=IN_22;
float angle=IN_24;

   iStringStr(sp,speed,"%.0f");
   iStringStr(ang,angle,"%.0f");
   iStringStr(left,timeleft/60,"%.0f");
   iObjectTextSet(OBJ_0,"Speed:  "+sp+"\rAngle:  "+ang+"\rTime: "+left);

timeleft--;
}

Saving of time: (on my PC)
1 TextPrint loads 7-8 sec.
3 ValuePrints - 14 sec.
4 ValuePrints - 18 sec.
5 ValuePrints - 22 sec. and so on.
« Last Edit: September 24, 2010, 11:57:25 AM by Alec »

psikotropico

« Reply #1 on: September 24, 2010, 12:45:57 PM »
congratz... you're walking in the right direction... there are some other code tips that will save you a lot of objects, loading times and framerate...

lately I'm only think about how can I make a complete game without using the scroll bar in the objects list...

jestermon

« Reply #2 on: September 24, 2010, 02:41:10 PM »
It takes time to learn the secrets of iPrint, but its a great tool.
Try this tip.
Code: [Select]

string S;  //This gets used for printing everything
int PRINT = OBJ_xx;  //the Textprint object ,whatever xx is equal to


void Main()
{
   int myNumber = 123;  //an int
   float myDecimal = 321.222; //a float
   string myString = "My string"; // a string

  //Now we print it all using 1 line of code
  iPrint(S= myNumber + ", " + myDecimal + ", " + myString, -14,11,PRINT);

  //What this does is adds everything to the S string, and prints it out at
  //coordinates -14,11 on the screen, using PRINT, the TextPrint Object

  //Or you can do the following with the TextPrint
  iObjectTextSet(PRINT, S= myNumber + ", " + myDecimal + ", " + myString);

  //There are many ways to have a lot of fun. But the iStringStr() is useful
  //for formatting the numbers.
}



Way to go.. You are getting there fast :)
« Reply #3 on: September 25, 2010, 01:44:18 AM »
Yes, using one textprint and the iPrint() function should be very effecient (loading time wise) :)
« Reply #4 on: September 25, 2010, 02:01:01 AM »
Thanks psikoT. I think others too could share their tips for optimization a game  :).
Quote
there are some other code tips that will save you a lot of objects, loading times and framerate...
You put in into my head that I use iFrameRate(bool) in my projects to watch framerate.I haven't done it before.
Quote
lately I'm only think about how can I make a complete game without using the scroll bar in the objects list...
Perhaps, you have hundreds objects in your game.
I guess having lots of objects you make your game funnier.
I foresee I'll meet the same problem soon.
Can one do anything about it any way ?
« Last Edit: September 25, 2010, 09:01:23 PM by Alec »
« Reply #5 on: September 25, 2010, 02:05:48 AM »
Quote
It takes time to learn the secrets of iPrint, but its a great tool.
Yes it is and that is another way to save a time.
Thanks.
« Reply #6 on: September 25, 2010, 02:11:11 AM »
Quote
Yes, using one textprint and the iPrint() function should be very effecient (loading time wise) :)
Yes. Let's look for and post other tips on the subject  :).
« Reply #7 on: September 25, 2010, 05:13:44 PM »
I'd like iPrint() better if you could scale and change color for each iPrint() (like you can do via script with the text object). that way you could really have all sort of different texts on screen loading just one.
Crashing Boxes - winner of the 3d games category at the 5th Uruguayan video game contest
get a copy for your iPad/iPhone!
« Reply #8 on: October 04, 2010, 10:11:45 PM »
is there a little demo of this (using iprint) floating around somewhere? I'm tossing some ideas for creating a dialog system around in my head, and  I think something like this would be a good starting point.

But being able to set the screen position independent of the valueprint or textprint object would be primarily important in my situation.  Although I have never messed with it, I think a solution to that end should be pretty easy to come up with.
« Last Edit: October 04, 2010, 10:19:48 PM by electron_theory »

psikotropico

« Reply #9 on: October 04, 2010, 11:18:39 PM »
using iPrint() couldn't be easier:

Quote
iPrint(string,float,float,OBJ_X)
   Print the specified string by using the font and character settings as configured in the specified
   TextPrint object
   string = text (255 characters max). Multi-line text is supported (use '\r' to specify a new line character).
   float,float = screen position. Note that resulting text location depends on source TextPrint object settings.
   OBJ_X = TextPrint object handle.
   NOTE: this function will only print the text once. In order to display a permanet text it must be executed
         at every script loop.

« Reply #10 on: October 05, 2010, 07:28:32 AM »
Yes you are absolutely right, That could not be easier!!  I guess I just have a panic attack the moment editing/parsing text is mentioned. :D

jestermon

« Reply #11 on: October 05, 2010, 04:22:46 PM »
Take a peek at some of  the posts I've done in the Elite - thread, many of them are extensively based on iPrint() .. Also have a peek at a post I did for a simple gui which gives an example of doing a text input field.
Hope this helps
« Reply #12 on: October 29, 2010, 09:44:59 PM »
Here's an idea i had -

In my current project i have 11 skin-mesh's (10, one for each player),  where only the location (X,Y,Z)   values are used, but i assume that 3drad's network process's sync ALL the networked skinmesh properties in a project.

I'm wondering if it possible to use the unused & synced rotation skinmesh data as a communications path ?.

Something like this -

360 degrees of rotation are converted (1 degree = A, 2 = B, 3 = C) ect.

A script in the server and client programs just reads the rotation values & converts them to the equivalent letter then pass's them to a text print process to create a chat box for our networked projects.

Is this possible ?.

Is this to involved to use ?

Would this, if possible even be efficient enough to even save any bandwidth ?

Is this just silly & its better to use the "text" script functions ?.
« Reply #13 on: October 29, 2010, 09:56:15 PM »
Additional..

See i want to add a chat box of say, 4 lines x 150 characters, that allows scrolling up & down to my networked projects.

That and / or voice chat add-on programs like -

http://www.ventrilo.com/  or
MSN voice /video chat  etc.

jestermon

« Reply #14 on: October 30, 2010, 08:24:53 AM »
Network speed is usually very fast, and you have no need to resort to compression methods for something like a chat system. Since you are only passing a few bytes at a time, the effort of encrypting of compressing may actually take more time that it would to just send the raw data. For the basics of a chat program that gives scroll chat history and text input, take a peek at a project I uploaded some time ago
http://www.3drad.com/forum/index.php?topic=4358.0
Pages: [1] 2