About Store Forum Documentation Contact



Post Reply 
How to reduce this code?
Author Message
Babulesnik Offline
Member

Post: #1
How to reduce this code?
void rezultat()
{
if (kub_act_1.sleep())
{
if (cskel_1.getPoint("4").pos.y<=pos)D.text(-1.20,0.95,S+"< 3 >");
if (cskel_1.getPoint("1").pos.y<=pos)D.text(-1.20,0.95,S+"< 6 >");
if (cskel_1.getPoint("3").pos.y<=pos)D.text(-1.20,0.95,S+"< 4 >");
if (cskel_1.getPoint("6").pos.y<=pos)D.text(-1.20,0.95,S+"< 1 >");
if (cskel_1.getPoint("2").pos.y<=pos)D.text(-1.20,0.95,S+"< 5 >");
if (cskel_1.getPoint("5").pos.y<=pos)D.text(-1.20,0.95,S+"< 2 >");
}
if (kub_act_2.sleep())
{
if (cskel_2.getPoint("4").pos.y<=pos)D.text(-1.0,0.95,S+"< 3 >");
if (cskel_2.getPoint("1").pos.y<=pos)D.text(-1.0,0.95,S+"< 6 >");
if (cskel_2.getPoint("3").pos.y<=pos)D.text(-1.0,0.95,S+"< 4 >");
if (cskel_2.getPoint("6").pos.y<=pos)D.text(-1.0,0.95,S+"< 1 >");
if (cskel_2.getPoint("2").pos.y<=pos)D.text(-1.0,0.95,S+"< 5 >");
if (cskel_2.getPoint("5").pos.y<=pos)D.text(-1.0,0.95,S+"< 2 >");
}
if (kub_act_3.sleep())
{
if (cskel_3.getPoint("4").pos.y<=pos)D.text(-0.8,0.95,S+"< 3 >");
if (cskel_3.getPoint("1").pos.y<=pos)D.text(-0.8,0.95,S+"< 6 >");
if (cskel_3.getPoint("3").pos.y<=pos)D.text(-0.8,0.95,S+"< 4 >");
if (cskel_3.getPoint("6").pos.y<=pos)D.text(-0.8,0.95,S+"< 1 >");
if (cskel_3.getPoint("2").pos.y<=pos)D.text(-0.8,0.95,S+"< 5 >");
if (cskel_3.getPoint("5").pos.y<=pos)D.text(-0.8,0.95,S+"< 2 >");
}
if (kub_act_4.sleep())
{
if (cskel_4.getPoint("4").pos.y<=pos)D.text(-0.6,0.95,S+"< 3 >");
if (cskel_4.getPoint("1").pos.y<=pos)D.text(-0.6,0.95,S+"< 6 >");
if (cskel_4.getPoint("3").pos.y<=pos)D.text(-0.6,0.95,S+"< 4 >");
if (cskel_4.getPoint("6").pos.y<=pos)D.text(-0.6,0.95,S+"< 1 >");
if (cskel_4.getPoint("2").pos.y<=pos)D.text(-0.6,0.95,S+"< 5 >");
if (cskel_4.getPoint("5").pos.y<=pos)D.text(-0.6,0.95,S+"< 2 >");
}
if (kub_act_5.sleep())
{
if (cskel_5.getPoint("4").pos.y<=pos)D.text(-0.4,0.95,S+"< 3 >");
if (cskel_5.getPoint("1").pos.y<=pos)D.text(-0.4,0.95,S+"< 6 >");
if (cskel_5.getPoint("3").pos.y<=pos)D.text(-0.4,0.95,S+"< 4 >");
if (cskel_5.getPoint("6").pos.y<=pos)D.text(-0.4,0.95,S+"< 1 >");
if (cskel_5.getPoint("2").pos.y<=pos)D.text(-0.4,0.95,S+"< 5 >");
if (cskel_5.getPoint("5").pos.y<=pos)D.text(-0.4,0.95,S+"< 2 >");
}
}
01-08-2011 07:02 PM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #2
RE: How to reduce this code?
You can create a loop in each kub act so you will reduce it from 6 to 1... but you can make a loop in those acts as well so you have 2 loops.

REPAOD(acts, i).sleep()
REPAD(totalPoints, j)
if (acts[i].getPoint(j).pos.y<=pos)D.text(-0.4,0.95,S+"< "+ j +" >");


Im not 100% sure this will work but at least it will give you an idea smile

There is always evil somewhere, you just have to look for it properly.
(This post was last modified: 01-08-2011 07:14 PM by Dynad.)
01-08-2011 07:11 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #3
RE: How to reduce this code?
(01-08-2011 07:11 PM)Dynad Wrote:  You can create a loop in each kub act so you will reduce it from 6 to 1... but you can make a loop in those acts as well so you have 2 loops.

REPAOD(acts, i).sleep()
REPAD(totalPoints, j)
if (acts[i].getPoint(j).pos.y<=pos)D.text(-0.4,0.95,S+"< "+ j +" >");


Im not 100% sure this will work but at least it will give you an idea smile

Thank you very much.
01-08-2011 07:18 PM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #4
RE: How to reduce this code?
use Arrays
01-08-2011 07:20 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #5
RE: How to reduce this code?
(01-08-2011 07:20 PM)Esenthel Wrote:  use Arrays

If to you not difficultly give an example please
(01-08-2011 07:20 PM)Esenthel Wrote:  use Arrays

Actor kub_act[4]; Thus?
(This post was last modified: 01-08-2011 07:56 PM by Babulesnik.)
01-08-2011 07:35 PM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #6
RE: How to reduce this code?
yes
01-08-2011 08:05 PM
Find all posts by this user Quote this message in a reply
menajev Offline
Member

Post: #7
RE: How to reduce this code?
Learn c++ before starting with engines.
01-08-2011 09:59 PM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #8
RE: How to reduce this code?
(01-08-2011 09:59 PM)menajev Wrote:  Learn c++ before starting with engines.

Well as you can see he made a function but not very efficient... so your reply is kinda useless since he is asking for some tips/snippets..

There is always evil somewhere, you just have to look for it properly.
01-08-2011 10:57 PM
Visit this user's website Find all posts by this user Quote this message in a reply
menajev Offline
Member

Post: #9
RE: How to reduce this code?
Yea. I just can't believe that someone who know c++ good enough to start coding on engines couldn't know how to collapse it to one for() function.
01-08-2011 11:59 PM
Find all posts by this user Quote this message in a reply
Masterxilo Offline
Member

Post: #10
RE: How to reduce this code?
Maybe he's starting C++ programming with EE which is not such a bad idea I think. I'd have enjoyed beginning that way.
01-09-2011 02:04 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #11
RE: How to reduce this code?
(01-09-2011 02:04 AM)Masterxilo Wrote:  Maybe he's starting C++ programming with EE which is not such a bad idea I think. I'd have enjoyed beginning that way.

Indeed, I barely knew anything about programming before I ended up with Esenthel. and I've tried to learn through quite a few books, but most books aren't worth the paper and certainly not the money..

(01-08-2011 09:59 PM)menajev Wrote:  "Learn c++ before starting with engines."

Why? not every engine uses C++, and if you mean before starting with a C++ engine(which I think you do).
Like MasterXilo said, learning programming through the means of what you want to do is not a bad idea.
In this case, getting graphical returns of what you are doing is alot easier to learn from compared to boring console programming.
(This post was last modified: 01-09-2011 11:52 PM by Zervox.)
01-09-2011 11:50 PM
Find all posts by this user Quote this message in a reply
Post Reply