Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411423 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 18, 2024, 12:03:15 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)The grumpy old programmer room
Pages: 1 ... 202 203 [204] 205 206 ... 295
Print
Author Topic: The grumpy old programmer room  (Read 738131 times)
mr_gant
Level 0
**


View Profile
« 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
Level 0
***


View Profile
« 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  Sad
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
Level 0
***


View Profile
« 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
Level 1
*



View Profile WWW
« 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
Level 9
****

C++ professional, game dev sparetime


View Profile WWW
« 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
Level 10
*****



View Profile
« 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

Rusk
Level 1
*


View Profile
« Reply #4067 on: April 23, 2013, 04:04:55 AM »

To get a number 0-1, you could use the modulo operator: 0.0001 * (N % 10000). Coffee
Logged
Fallsburg
Level 10
*****


Fear the CircleCat


View Profile
« 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
Level 2
**


View Profile
« 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
Level 10
*****


Fear the CircleCat


View Profile
« 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
Level 2
**


View Profile
« 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
Level 10
*****


Fear the CircleCat


View Profile
« Reply #4072 on: April 23, 2013, 09:14:32 AM »

Well, it depends on a lot things but something like:

Code:
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
Level 2
**


View Profile
« 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
Level 10
*****


Fear the CircleCat


View Profile
« Reply #4074 on: April 25, 2013, 05:35:52 PM »

Are you doing something like:
Code:
   ...
  if (JumpPressed()){
    vy += 10;
  }
  ...

Because that would get the behavior you are seeing.

Instead you'd want something like:

Code:
   ...
  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
Level 2
**


View Profile
« Reply #4075 on: April 25, 2013, 07:39:42 PM »

Are you doing something like:
Code:
   ...
  if (JumpPressed()){
    vy += 10;
  }
  ...

Because that would get the behavior you are seeing.

Instead you'd want something like:

Code:
   ...
  if (JumpPressed()){
    vy = 10;
  }
  ...


Brilliant! working like a charm :D
Logged

R.D.
Level 2
**


Making a game about balls. Yepp.


View Profile WWW
« 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

SoulSharer
Level 1
*



View Profile
« Reply #4077 on: May 02, 2013, 09:49:13 AM »

Dat Unicode, man, Dat Unicode.  Crazy
Logged

Twitter: twitter.com/SoulSharer
Skype: disturbedfearless
TheLastBanana
Level 9
****



View Profile WWW
« 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. No No NO
Logged
Klaim
Level 10
*****



View Profile WWW
« 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

Pages: 1 ... 202 203 [204] 205 206 ... 295
Print
Jump to:  

Theme orange-lt created by panic