Users browsing this thread: 11 Guest(s)
Non-Named (More debugging)
That's true.

Most of it can be massively cut down, though.

For example, instead of having a massive hierarchy of if/otherwise statements for player movement. I could do a single, simple if statement that checks if any of the movement keys were pressed, and applies X/Y speed based off variables. Below the script could be 2 if/otherwise if statements that change the X/Y speed off what keys were held down. It's far more shorter in terms of code than the method I have right now, and less checks are involved.

For example, my original movement code was 700-something lines long (Judge me for being a bad coder, please). While this new one is far smaller.

/* ======================== When Updating ========================= */
addWhenUpdatedListener(null, function(elapsedTime:Float, list:Array<Dynamic>):Void
{
if(wrapper.enabled)
{
if((isKeyDown("right") || (isKeyDown("left") || (isKeyDown("down") || isKeyDown("up")))))
{
if(isKeyDown("up"))
{
_Yspeed = asNumber(-10);
propertyChanged("_Yspeed", _Yspeed);
}
else if(isKeyDown("down"))
{
_Yspeed = asNumber(10);
propertyChanged("_Yspeed", _Yspeed);
}
if(isKeyDown("right"))
{
_Xspeed = asNumber(10);
propertyChanged("_Xspeed", _Xspeed);
}
else if(isKeyDown("left"))
{
_Xspeed = asNumber(-10);
propertyChanged("_Xspeed", _Xspeed);
}
actor.setXVelocity(_Xspeed);
actor.setXVelocity(_Yspeed);
}
else
{
actor.setXVelocity(0);
actor.setXVelocity(0);
}
}
});

}

override public function forwardMessage(msg:String)
{

}
}

It's neat, and clean. And if you're wondering what it looks like in visual code mode, it's just as clean.

[Image: hvHPXZi.png]

EDIT: This script could be even further optimized by running it so that it detects only when keys are pressed, instead of using an always updating script.

[Image: rWRAIgS.png]

While it looks longer, it'll use less memory as it doesn't check every frame. This doesn't support cornered movement, yet.
I like to make models in my free time. I also make weird games, too.
Reply
Thanked by:


Messages In This Thread
Non-Named (More debugging) - by Filler - 06-21-2016, 11:53 AM
RE: Non-Named (Engine testing phase) - by Filler - 09-22-2016, 11:56 PM
RE: Non-Named (Engine testing phase) - by Filler - 09-23-2016, 09:58 PM
RE: Non-Named (Engine testing phase) - by Filler - 09-26-2016, 06:18 AM
RE: Non-Named (Engine testing phase) - by iyenal - 09-26-2016, 07:22 AM
RE: Non-Named (Engine testing phase) - by Filler - 10-01-2016, 07:01 AM
RE: Non-Named (Engine testing phase) - by Filler - 10-02-2016, 07:40 PM
RE: Non-Named (Engine testing phase) - by Gors - 10-03-2016, 02:49 PM
RE: Non-Named (Engine testing phase) - by Filler - 10-04-2016, 11:44 PM
RE: Non-Named (Engine testing phase) - by iyenal - 10-05-2016, 09:19 AM
RE: Non-Named (Engine testing phase) - by Filler - 10-23-2016, 06:22 PM
RE: Non-Named (Engine testing phase) - by Filler - 11-07-2016, 06:51 PM
RE: Non-Named (Engine testing phase) - by Filler - 11-07-2016, 10:19 PM
RE: Non-Named (Engine testing phase) - by Filler - 11-08-2016, 06:43 PM
RE: Non-Named (Engine testing phase) - by Filler - 11-10-2016, 11:17 PM
RE: Non-Named (Engine testing phase) - by Filler - 11-11-2016, 06:56 PM
RE: Non-Named (Engine testing phase) - by Filler - 11-11-2016, 11:22 PM
RE: Non-Named (Engine testing phase) - by Gors - 11-16-2016, 07:04 AM
RE: Non-Named (Engine testing phase) - by Filler - 11-12-2016, 11:24 PM
RE: Non-Named (Engine testing phase) - by Filler - 11-16-2016, 01:05 AM
RE: Non-Named (Engine testing phase) - by Filler - 11-16-2016, 12:15 PM
RE: Non-Named (Engine testing phase) - by Filler - 11-16-2016, 10:42 PM
RE: Non-Named (Engine testing phase) - by Gors - 11-17-2016, 06:20 AM
RE: Non-Named (Engine testing phase) - by Filler - 11-17-2016, 11:36 PM
RE: Non-Named (Engine testing phase) - by iyenal - 11-18-2016, 11:39 AM
RE: Non-Named (Engine testing phase) - by Filler - 11-19-2016, 04:46 AM
RE: Non-Named (Engine testing phase) - by Filler - 12-08-2016, 02:18 AM
RE: Non-Named (Engine testing phase) - by iyenal - 12-08-2016, 01:02 PM
RE: Non-Named (Engine testing phase) - by Gors - 12-08-2016, 01:25 PM
RE: Non-Named (Engine testing phase) - by Filler - 12-08-2016, 02:18 PM
RE: Non-Named (Engine testing phase) - by Filler - 01-08-2017, 02:00 PM
RE: Non-Named (Engine testing phase) - by iyenal - 01-11-2017, 01:14 PM
RE: Non-Named (Engine testing phase) - by Filler - 01-14-2017, 04:49 PM
RE: Non-Named (Engine testing phase) - by Pingus! - 01-15-2017, 09:28 AM
RE: Non-Named (Engine testing phase) - by Filler - 01-16-2017, 10:03 PM
RE: Non-Named (Engine testing phase) - by Filler - 01-17-2017, 07:08 PM
RE: Non-Named (Engine testing phase) - by Gors - 01-18-2017, 07:47 AM
RE: Non-Named (Engine testing phase) - by Filler - 01-18-2017, 01:30 PM
RE: Non-Named (Engine testing phase) - by Filler - 01-20-2017, 08:51 PM
RE: Non-Named (Engine testing phase) - by Filler - 01-22-2017, 11:45 PM
RE: Non-Named (Engine testing phase) - by Filler - 01-28-2017, 12:42 AM
RE: Non-Named (Engine testing phase) - by Filler - 02-01-2017, 08:32 AM
RE: Non-Named (Engine testing phase) - by Filler - 02-13-2017, 09:07 PM
RE: Non-Named (Engine testing phase) - by iyenal - 02-14-2017, 05:35 AM
RE: Non-Named (Engine testing phase) - by puggsoy - 02-14-2017, 06:35 AM
RE: Non-Named (Engine testing phase) - by Filler - 02-14-2017, 07:05 AM
RE: Non-Named (Engine testing phase) - by Filler - 02-20-2017, 01:09 AM
RE: Non-Named (Engine testing phase) - by Filler - 02-26-2017, 01:45 AM
RE: Non-Named (Engine testing phase) - by Filler - 02-27-2017, 02:51 AM
RE: Non-Named (Engine testing phase) - by iyenal - 03-04-2017, 09:54 AM
RE: Non-Named (Engine testing phase) - by Filler - 03-04-2017, 08:05 PM
RE: Non-Named (Engine testing phase) - by Filler - 03-15-2017, 12:23 AM
RE: Non-Named (Engine testing phase) - by Gors - 03-15-2017, 08:08 AM
RE: Non-Named (Engine testing phase) - by Filler - 03-15-2017, 02:16 PM
RE: Non-Named (Engine testing phase) - by Filler - 03-16-2017, 09:53 PM
RE: Non-Named (Engine testing phase) - by Filler - 03-19-2017, 10:16 AM
RE: Non-Named (Engine testing phase) - by Filler - 03-25-2017, 11:47 AM
RE: Non-Named (Engine testing phase) - by Filler - 03-25-2017, 09:20 PM
RE: Non-Named (Engine testing phase) - by iyenal - 03-26-2017, 10:26 AM
RE: Non-Named (Engine testing phase) - by Filler - 04-01-2017, 07:59 AM
RE: Non-Named (Engine testing phase) - by Filler - 04-05-2017, 09:46 PM
RE: Non-Named (Engine testing phase) - by puggsoy - 05-27-2017, 07:18 PM
RE: Non-Named (Engine testing phase) - by Filler - 04-27-2017, 10:59 PM
RE: Non-Named (Engine testing phase) - by Filler - 05-07-2017, 12:06 PM
RE: Non-Named (Engine testing phase) - by Filler - 05-24-2017, 05:48 AM
RE: Non-Named (Engine testing phase) - by iyenal - 05-24-2017, 09:35 AM
RE: Non-Named (Engine testing phase) - by Filler - 05-25-2017, 09:16 PM
RE: Non-Named (Engine testing phase) - by Filler - 05-28-2017, 12:40 AM
RE: Non-Named (Engine testing phase) - by Filler - 06-11-2017, 10:36 PM
RE: Non-Named (Engine testing phase) - by iyenal - 06-13-2017, 03:44 AM
RE: Non-Named (Engine testing phase) - by Filler - 06-13-2017, 08:23 PM
RE: Non-Named (Engine testing phase) - by Filler - 06-14-2017, 05:55 PM
RE: Non-Named (Engine testing phase) - by puggsoy - 06-15-2017, 10:47 AM
RE: Non-Named (Engine testing phase) - by iyenal - 06-15-2017, 01:56 PM
RE: Non-Named (Engine testing phase) - by Filler - 06-16-2017, 06:45 PM
RE: Non-Named (Engine testing phase) - by puggsoy - 06-17-2017, 05:18 AM
RE: Non-Named (Engine testing phase) - by Filler - 06-17-2017, 11:56 AM
RE: Non-Named (Engine testing phase) - by puggsoy - 06-18-2017, 02:33 AM
RE: Non-Named (Engine testing phase) - by iyenal - 06-18-2017, 03:44 AM
RE: Non-Named (Engine testing phase) - by Filler - 06-18-2017, 03:44 PM
RE: Non-Named (Engine testing phase) - by puggsoy - 06-18-2017, 07:11 PM
RE: Non-Named (Engine testing phase) - by Filler - 06-18-2017, 08:37 PM
RE: Non-Named (Engine testing phase) - by puggsoy - 06-18-2017, 10:17 PM
RE: Non-Named (Engine testing phase) - by Gors - 06-19-2017, 07:55 AM
RE: Non-Named (Engine testing phase) - by Filler - 06-20-2017, 01:48 PM
RE: Non-Named (Engine testing phase) - by puggsoy - 06-20-2017, 04:48 PM
RE: Non-Named (Engine testing phase) - by Filler - 06-20-2017, 07:43 PM
RE: Non-Named (Engine testing phase) - by puggsoy - 06-21-2017, 02:29 AM
RE: Non-Named (Engine testing phase) - by Filler - 06-20-2017, 10:06 PM
RE: Non-Named (Engine testing phase) - by Filler - 06-23-2017, 01:43 AM
RE: Non-Named (Engine testing phase) - by puggsoy - 06-23-2017, 04:27 AM
RE: Non-Named (Engine testing phase) - by Filler - 06-25-2017, 02:38 AM
RE: Non-Named (Engine testing phase) - by puggsoy - 06-25-2017, 07:52 AM
RE: Non-Named (Engine testing phase) - by Filler - 06-25-2017, 06:54 PM
RE: Non-Named (Engine testing phase) - by Filler - 06-26-2017, 07:29 AM
RE: Non-Named (Engine testing phase) - by puggsoy - 06-26-2017, 08:48 AM
RE: Non-Named (Engine testing phase) - by Filler - 06-28-2017, 12:33 AM
RE: Non-Named (Engine testing phase) - by Filler - 06-28-2017, 12:57 AM
RE: Non-Named (Engine testing phase) - by Filler - 06-29-2017, 01:28 AM
RE: Non-Named (Engine testing phase) - by puggsoy - 06-29-2017, 10:00 AM
RE: Non-Named (Engine testing phase) - by Filler - 06-29-2017, 10:11 AM
RE: Non-Named (Engine testing phase) - by puggsoy - 06-29-2017, 10:15 AM
RE: Non-Named (Engine testing phase) - by Filler - 06-29-2017, 10:32 AM
RE: Non-Named (Engine testing phase) - by Filler - 06-30-2017, 11:07 AM
RE: Non-Named (Engine testing phase) - by Filler - 07-03-2017, 09:47 AM
RE: Non-Named (Engine testing phase) - by Filler - 07-03-2017, 09:01 PM
RE: Non-Named (Engine testing phase) - by Filler - 07-05-2017, 03:20 PM
RE: Non-Named (Engine testing phase) - by Filler - 07-06-2017, 11:31 AM
RE: Non-Named (Engine testing phase) - by Filler - 07-09-2017, 06:09 PM
RE: Non-Named (Engine testing phase) - by Filler - 07-13-2017, 10:06 PM
RE: Non-Named (Engine testing phase) - by Filler - 07-14-2017, 11:11 AM
RE: Non-Named (Engine testing phase) - by Filler - 07-16-2017, 07:58 PM
RE: Non-Named (Engine testing phase) - by Filler - 07-17-2017, 12:43 AM
RE: Non-Named (Engine testing phase) - by Filler - 07-17-2017, 03:50 AM
RE: Non-Named (Engine testing phase) - by Filler - 07-18-2017, 03:31 AM
RE: Non-Named (Engine testing phase) - by Filler - 07-20-2017, 02:48 AM
RE: Non-Named (Engine testing phase) - by Filler - 07-20-2017, 09:21 PM
RE: Non-Named (Engine testing phase) - by Filler - 07-23-2017, 05:02 AM
RE: Non-Named (Engine testing phase) - by Filler - 07-23-2017, 07:58 PM
RE: Non-Named (Engine testing phase) - by puggsoy - 07-24-2017, 08:10 AM
RE: Non-Named (Engine testing phase) - by Filler - 07-24-2017, 08:24 AM
RE: Non-Named (Engine testing phase) - by iyenal - 07-24-2017, 08:29 AM
RE: Non-Named (Engine testing phase) - by Filler - 07-24-2017, 08:42 AM
RE: Non-Named (Engine testing phase) - by Filler - 07-24-2017, 09:45 AM
RE: Non-Named (Engine testing phase) - by iyenal - 07-24-2017, 09:48 AM
RE: Non-Named (Engine testing phase) - by Filler - 07-24-2017, 04:31 PM
RE: Non-Named (Engine testing phase) - by Filler - 07-25-2017, 01:02 PM
RE: Non-Named (Engine testing phase) - by Filler - 07-26-2017, 08:06 PM
RE: Non-Named (Engine testing phase) - by Filler - 07-28-2017, 05:57 PM
RE: Non-Named (Engine testing phase) - by Filler - 07-29-2017, 05:48 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-04-2017, 12:35 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-07-2017, 10:03 AM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-07-2017, 05:06 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-08-2017, 09:11 AM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-08-2017, 08:02 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-11-2017, 01:08 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-11-2017, 02:11 PM
RE: Non-Named (Writing 'n stuffs) - by Silversea - 08-12-2017, 03:13 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-12-2017, 06:04 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-13-2017, 03:10 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-13-2017, 09:06 PM
RE: Non-Named (Writing 'n stuffs) - by Silversea - 08-13-2017, 09:37 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-13-2017, 09:46 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-14-2017, 02:59 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-15-2017, 09:07 PM
RE: Non-Named (Writing 'n stuffs) - by kadashyto - 08-15-2017, 10:30 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-15-2017, 10:54 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-16-2017, 06:38 PM
RE: Non-Named (Writing 'n stuffs) - by Silversea - 08-16-2017, 06:56 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-16-2017, 08:04 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-19-2017, 09:20 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-20-2017, 06:46 PM
RE: Non-Named (Writing 'n stuffs) - by iyenal - 08-21-2017, 10:17 AM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-24-2017, 07:47 AM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-26-2017, 01:10 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-27-2017, 05:32 AM
RE: Non-Named (Writing 'n stuffs) - by Cloud6625 - 08-27-2017, 05:43 AM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-27-2017, 06:19 AM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-27-2017, 10:30 AM
RE: Non-Named (Writing 'n stuffs) - by Filler - 08-29-2017, 07:24 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 09-01-2017, 10:02 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 09-07-2017, 01:14 AM
RE: Non-Named (Writing 'n stuffs) - by Filler - 09-09-2017, 02:53 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 09-17-2017, 05:33 PM
RE: Non-Named (Writing 'n stuffs) - by iyenal - 09-21-2017, 06:25 AM
RE: Non-Named (Writing 'n stuffs) - by Filler - 09-21-2017, 10:30 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 09-30-2017, 09:10 PM
RE: Non-Named (Writing 'n stuffs) - by iyenal - 10-01-2017, 03:57 AM
RE: Non-Named (Writing 'n stuffs) - by Filler - 10-01-2017, 12:12 PM
RE: Non-Named (Writing 'n stuffs) - by Silversea - 10-01-2017, 02:57 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 10-04-2017, 06:39 PM
RE: Non-Named (Writing 'n stuffs) - by puggsoy - 10-05-2017, 07:33 AM
RE: Non-Named (Writing 'n stuffs) - by Filler - 10-06-2017, 04:54 AM
RE: Non-Named (Writing 'n stuffs) - by iyenal - 10-06-2017, 02:15 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 10-07-2017, 07:44 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 10-14-2017, 06:54 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 10-22-2017, 12:47 AM
RE: Non-Named (Writing 'n stuffs) - by iyenal - 10-22-2017, 02:16 AM
RE: Non-Named (Writing 'n stuffs) - by Filler - 10-22-2017, 01:54 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 10-27-2017, 02:36 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 10-27-2017, 06:13 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 10-28-2017, 06:05 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 10-31-2017, 09:52 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 11-04-2017, 09:52 PM
RE: Non-Named (Writing 'n stuffs) - by Filler - 11-05-2017, 12:41 AM
RE: Non-Named (Writing 'n stuffs) - by Filler - 11-05-2017, 07:16 PM
RE: Non-Named (More debugging) - by Filler - 11-11-2017, 08:25 PM
RE: Non-Named (More debugging) - by Filler - 11-26-2017, 02:52 AM
RE: Non-Named (More debugging) - by Filler - 11-29-2017, 11:56 PM
RE: Non-Named (More debugging) - by iyenal - 12-04-2017, 12:24 PM
RE: Non-Named (More debugging) - by Filler - 12-26-2017, 07:57 PM
RE: Non-Named (More debugging) - by Filler - 12-31-2017, 03:44 PM
RE: Non-Named (More debugging) - by Filler - 01-02-2018, 06:56 PM
RE: Non-Named (More debugging) - by iyenal - 01-03-2018, 06:03 AM
RE: Non-Named (More debugging) - by Filler - 01-03-2018, 09:10 AM
RE: Non-Named (More debugging) - by Filler - 01-04-2018, 12:41 PM
RE: Non-Named (More debugging) - by iyenal - 01-04-2018, 12:51 PM
RE: Non-Named (More debugging) - by Filler - 01-06-2018, 01:47 PM
RE: Non-Named (More debugging) - by Filler - 01-09-2018, 11:09 PM
RE: Non-Named (More debugging) - by Filler - 01-10-2018, 02:10 AM
RE: Non-Named (More debugging) - by iyenal - 01-10-2018, 09:07 AM
RE: Non-Named (More debugging) - by Filler - 01-11-2018, 07:45 PM
RE: Non-Named (More debugging) - by Filler - 01-12-2018, 05:17 PM
RE: Non-Named (More debugging) - by iyenal - 01-13-2018, 05:18 AM
RE: Non-Named (More debugging) - by Filler - 01-13-2018, 04:17 PM
RE: Non-Named (More debugging) - by Filler - 01-14-2018, 11:12 PM
RE: Non-Named (More debugging) - by iyenal - 01-15-2018, 06:28 AM
RE: Non-Named (More debugging) - by Filler - 01-16-2018, 08:30 AM
RE: Non-Named (More debugging) - by iyenal - 01-16-2018, 12:52 PM
RE: Non-Named (More debugging) - by Filler - 01-23-2018, 11:36 AM
RE: Non-Named (More debugging) - by iyenal - 01-24-2018, 10:06 AM
RE: Non-Named (More debugging) - by Filler - 02-17-2018, 09:05 PM
RE: Non-Named (More debugging) - by iyenal - 02-18-2018, 05:38 AM
RE: Non-Named (More debugging) - by Filler - 03-17-2018, 11:23 PM
RE: Non-Named (More debugging) - by Filler - 04-01-2018, 10:21 PM
RE: Non-Named (More debugging) - by iyenal - 04-03-2018, 05:50 AM
RE: Non-Named (More debugging) - by Filler - 06-26-2018, 09:37 PM
RE: Non-Named (More debugging) - by Filler - 07-28-2018, 11:34 AM
RE: Non-Named (More debugging) - by DrexusNui - 05-10-2023, 01:52 PM

Forum Jump: