mr_gant
|
|
« Reply #4060 on: April 22, 2013, 04:53:40 PM » |
|
Or it's not the back faces but that it's overlapping front faces and blending additively?
This was exactly what it was. Thanks. I was representing elevation on the alpha channel, which works fine when everything's flat, didn't even think about the consequences.
|
|
« Last Edit: April 22, 2013, 08:52:47 PM by mr_gant »
|
Logged
|
|
|
|
cubertron
|
|
« Reply #4061 on: April 22, 2013, 09:05:40 PM » |
|
I have a number X and I want its value to always lie between 0 and 1 , how can i do it? Sorry for asking an offtopic question here
|
|
|
Logged
|
|
|
|
ink.inc
Guest
|
|
« Reply #4062 on: April 22, 2013, 09:29:38 PM » |
|
if x>1 x=1 else if x<0 x=0
??????????
|
|
|
Logged
|
|
|
|
cubertron
|
|
« Reply #4063 on: April 22, 2013, 10:19:05 PM » |
|
if x>1 x=1 else if x<0 x=0
??????????
Here's an example, X = 523 , always between 0 - 1 meaning it could be something like 0.122 It is kind of possible to do if the MAXIMUM NUMBER is defined, but in my case its not
|
|
|
Logged
|
|
|
|
X-Tender
|
|
« Reply #4064 on: April 22, 2013, 10:59:28 PM » |
|
just a rough idea, you could use the MAX value of the dataType X is (float/Number/int/uint ect.)
e.g. with AS3 code. var x:Number = 123.5; var newX:Number = 1 / Number.MAX_VALUE * x;
|
|
|
Logged
|
|
|
|
Schrompf
|
|
« Reply #4065 on: April 22, 2013, 11:28:09 PM » |
|
Without a maximum value the only thing you could do is an asymptote. For example:
y = 1 - e^-x
|
|
|
Logged
|
Snake World, multiplayer worm eats stuff and grows DevLog
|
|
|
bateleur
|
|
« Reply #4066 on: April 23, 2013, 12:51:42 AM » |
|
Without a maximum value the only thing you could do is an asymptote. For example:
y = 1 - e^-x Seems like a good approach, but there are still two potential problems: 1) You need an asymptote at the low end too. 2) You'll get a lot of very similar values out depending on the real range of the numbers. Problem 1) is relatively easy to avoid, for example by scaling the outputs for positive x into the range (0.5,1) and then mapping -f(-x) into the (0,0.5) range. Problem 2) is, in general, impossible to solve without knowing something about the input values. However, if (say) 523 is known to be a typical input value then amending the function to something like y = 1 - e^-(x/1000) should give a slightly better spread of output values.
|
|
|
Logged
|
|
|
|
|
Fallsburg
|
|
« Reply #4068 on: April 23, 2013, 04:25:38 AM » |
|
Hmm... well this is a weird request. There are a lot of ways to do this, so perhaps you should be more specific. What properties do you want this mapping to have?
What Rusk said to do is just a very bad hashing algorithm, which got me thinking that you could use a good hashing algorithm. But that's only if you want some sort of pseudo-random response.
So, yeah, if you want a good answer, you will need to offer up more information. How is this being used? What is your intention with it?
|
|
|
Logged
|
|
|
|
indie11
|
|
« Reply #4069 on: April 23, 2013, 07:36:22 AM » |
|
Trying to code Dashing in a platformer game but not getting the right results, has anyone here implemented dashing? What logic have you used?
|
|
|
Logged
|
|
|
|
Fallsburg
|
|
« Reply #4070 on: April 23, 2013, 08:11:27 AM » |
|
I've implemented dashing, but there are a lot of ways one can go about it. Are you going for the standard "Double tap in a direction" or something else?
|
|
|
Logged
|
|
|
|
indie11
|
|
« Reply #4071 on: April 23, 2013, 08:24:42 AM » |
|
I've implemented dashing, but there are a lot of ways one can go about it. Are you going for the standard "Double tap in a direction" or something else?
Yes, I am going for the standard double tap. I want to write a generic dashing function which works for both the left and right side instead of making separate cases for each
|
|
|
Logged
|
|
|
|
Fallsburg
|
|
« Reply #4072 on: April 23, 2013, 09:14:32 AM » |
|
Well, it depends on a lot things but something like: float timeOfLastHorizontalInput = 99; float dashTimeout = 0.25; float deadzone = 0.1; float lastDirection = 0; bool stoppedPressing = false;
void update(float deltaTime){ float horizontalInput = GetInputAxis("Horizontal"); //Assumes -1 to 1 scale // This could also be something like -GetInput("Left") + GetInput("Right") or however input is handled
float absHorizontalInput = Math.abs(horizontalInput); float currentDirection = Math.sign(horizontalInput);
timeOfLastHorizontalInput += deltaTime;
if (absHorizontalInput > deadzone){ if (stoppedPressing && timeOfLastHorizontalInput <= dashTimeout && lastDirection == currentDirection){ //DO DASH } lastDirection = currentDirection; timeOfLastHorizontalInput = 0; stoppedPressing = false; } else { stoppedPressing = true; } }
That's a quickly paraphrased version of what I implemented in Unity. Depending on how you get input, you'll have to change it around (and it might be easier, since Unity doesn't have a convenient way to get JustPressed information for horizontal and vertical input). Caveat, as this is just a quick from memory paraphrase, I won't claim that this actually works, but it should be close.
|
|
|
Logged
|
|
|
|
indie11
|
|
« Reply #4073 on: April 25, 2013, 05:17:56 PM » |
|
Thanks Fallsburg I succeeded to make a generic dashing algorithm that works for both direction.
While trying double jump I am facing a weird problem, the scenarios:
-Player single jump's -> while going up if player double jump's, the player gets a very high boost -Player single jump's -> while going down if player double jump's, the player gets a very less or almost close to no boost
I am applying gravity in the normal fashion as done in platform games, what can be the problem here
|
|
|
Logged
|
|
|
|
Fallsburg
|
|
« Reply #4074 on: April 25, 2013, 05:35:52 PM » |
|
Are you doing something like: ... if (JumpPressed()){ vy += 10; } ...
Because that would get the behavior you are seeing. Instead you'd want something like: ... if (JumpPressed()){ vy = 10; } ...
The other thing to be aware of is jumping while on a moving platform. If the platform is moving up, you'll want to boost the players jump by the speed (or a slight factor more, say 1.2 times) of the platform. If it is moving down, let the player jump as normal.
|
|
|
Logged
|
|
|
|
indie11
|
|
« Reply #4075 on: April 25, 2013, 07:39:42 PM » |
|
Are you doing something like: ... if (JumpPressed()){ vy += 10; } ...
Because that would get the behavior you are seeing. Instead you'd want something like: ... if (JumpPressed()){ vy = 10; } ...
Brilliant! working like a charm :D
|
|
|
Logged
|
|
|
|
R.D.
|
|
« Reply #4076 on: April 26, 2013, 12:02:03 PM » |
|
I hate it when a gui framework says it is "dynamic" and "flexible" but hides every attribute with not getters and misses important features (srsly, insets or at least padding and some sort of state system plz >:|)
|
|
|
Logged
|
|
|
|
|
TheLastBanana
|
|
« Reply #4078 on: May 07, 2013, 12:29:49 PM » |
|
I'm putting together a portfolio site, and everything is working nicely except for one damn thing. I rolled my own jQuery slideshow module. Basically, it just moves a div around within a smaller frame, so it means every slide "frame" can have different content types. This is super useful, because some of the slides contain text or videos instead of images. The problem is, if I include a video and go to a different frame, it keeps playing. Kind of minor, but still annoying. So, I had to go switch around all my code to use the YouTube Javascript API. Not a problem! Everything is working nicely... except in fucking Internet Explorer, of course. For some absolutely bizarre reason, everything loads in fine, the videos are embedded, and their ready functions are called — but if you actually try to pause the video, it fails and claims that the object doesn't support that function. Okay, I said, let's try the iFrame API. Perhaps it'll fare better! So I uproot all my code, get it working in Firefox... and now it doesn't work in Chrome OR IE, because the function that should be triggered when the API is fully loaded only actually triggers in Firefox. Making this even more obnoxious is that the YouTube API only works locally in Firefox, so to test my page in Chrome or IE, I have to upload it to a webserver first. I've been trying to solve this one issue for days. I'm probably doing something completely wrong, and I'm sure I'll find it... but in the meantime, I want to tear my eyes out.
|
|
|
Logged
|
|
|
|
Klaim
|
|
« Reply #4079 on: May 07, 2013, 01:34:10 PM » |
|
Are you doing something similar to that? http://demo.artofsequence.org/You can take the code if you see how to use it, I made it MIT license.
|
|
|
Logged
|
|
|
|
|