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]

Author Topic: Help with script  (Read 304 times)

« on: November 05, 2013, 12:02:04 PM »
Hi.

I want write the script that Each Right key is down change opacity my sprites.
I wrote this script and work very well but I think this way is not correct.I use count++ for delay but when I hold down Right key and count = 10 change my Next sprite opacity. Now I want Each Right key is down and release, change opacity my sprites. already i wrote some script like this (with Boolean) but I don't know why don't work with Boolean.

Code: [Select]
int SelectedColor = IN_330;
int move = 1;
int count = 0;

void Main()
{

   if (iKeyDown(iKeyCode("DIK_RIGHT")) && SelectedColor == 1 && move == 1)

   {
      move = 2;
   }

   if (move == 2)
   {
      OUT_66 = 0.02;
      OUT_88 = 1;
   }

   if (iKeyDown(iKeyCode("DIK_RIGHT")) && SelectedColor == 1 && move == 2)

   {
      count ++;
      if (count == 10)
      {
      move = 3;
      }
   }

   if (move == 3)
   {
      OUT_66 = 1;
      OUT_88 = 0.02;

      OUT_132 = 0.02;
      OUT_154 = 1;
      count = 0;
   }

Thanks
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
« Reply #1 on: November 05, 2013, 01:12:39 PM »
There might be multiple ways to do this (and I can see this is probably for your menu system), but for now if it works, use it.  Optimizing comes later.
« Reply #2 on: November 06, 2013, 03:39:55 AM »
Quote
(and I can see this is probably for your menu system)
No, it's for select color.I write mouse script and now I want write new script for Keyboard and joystick.

Quote
but for now if it works, use it.  Optimizing comes later.

Yes work but I want write once and I do not have time for optimize again. if there is better way please guide me.

thanks.
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
« Reply #3 on: November 06, 2013, 09:35:02 AM »
Ahaha you almost got me there.  I raged, but then I took it back because I won't be spoiled like the others on here.

Behdadsoft, I know you want to be able to just write the code, make it work, and forget about it, but that's just not how game programming works, or any programming for that matter.

You need to understand the concept of code iterations.  It is POSSIBLE to write a script that works and you never have to mess with it again, but 99.9999999999999999% of the time you are forced to change your code during the project to make it better or to add/subtract stuff from it.  You'll also have to deal with getting multiple scripts to communicate with each other and independently at the same time, which will require more re-working, re-writing, and a pile of copy pasta and bug testing. 

Your method concept of 'set it and forget it' will not hold for the life of the project.  I will still help you knowing this, but I ask you to reconsider your position on script writing.

In this example, you are trying to offer support for 3 input devices when we don't even have a test model of the game to see if even the keyboard inputs work.  This is the kind of thing that shoots you in the foot early.  That's my guidance for now.
« Reply #4 on: November 07, 2013, 06:40:32 AM »
OK, I write this script Better than before and now good working.  ;D
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
Pages: [1]