Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 232 233 [234] 235 236 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 883287 times)

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3495 on: November 16, 2012, 05:54:17 am »

Splitting friction into traction and drag is a good idea, and is easily done based on the current speed-direction.

Still not sure how to implement force-as-a-motor, though. Drag becomes too large a factor when going uphill, and when going downhill or rounding a curve I'd like to "stick" to the ground instead of lifting off... Setting the speed directly will negate all the nifty parameters I want the player to be able to customise (heavier armor means clunkier movement, less high jumps).
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3496 on: November 16, 2012, 05:58:46 am »

Well I'm still ot 100% sure how to solve such problems... I guess you could make ramps a special case that convert speed between the X and Y axis. So, for example, if a ramp adds c to your Y velocity to lift you up, it also takes c from your X velocity. I'm not sure, not something I have played with.

http://www.metanetsoftware.com/technique/tutorialA.html

They have. If that is in any way helpful.

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3497 on: November 16, 2012, 06:19:53 am »

That won't work, I've got an "out of the box" physics solution. It's just that platformers are really hard to make in a physics-based engine.

Hmm, I could make "climbing" sensors, as my current "player" hitbox looks like this:
Code: [Select]
____
|  |
|  |
\__/
With one sensor on the bottom for sensing "I'm on the ground", and I hoped the slopes would help in climbing ;) Adding two more, slightly higher, sensors left and right-bottom, could help in determining if we're on a slope, and add a Y-upwards force. And then also implement two lower sensors to initiate a downwards force to improve "sticking" to the floor on downward slopes, but have normal gravity when falling off of cliffs or steep slopes.
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3498 on: November 16, 2012, 06:30:37 am »

Ok so I'm reading an article on how collision detection was done in Sonic the hedgehog.
http://info.sonicretro.org/SPG:Solid_Tiles
I know that it was tile based, but the general concept is there. What ever the actor is colliding with sets the state for how the actor behaves (This would explain why jumping at walls that you could also run up would cause you to stick to them, but other walls you wouldn't) so instead of sensors, you could have your level objects change the state of the actor. Might be better, might be worse.

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3499 on: November 16, 2012, 06:48:23 am »

I see, but that's still "mario-style" perfect platformer behaviour, which is a lot more straightforward. I'm just going to try the quad-sensor approach when I get home, see if it works, and if it does I'll my a first attampt somewhere.
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

alexandertnt

  • Bay Watcher
  • (map 'list (lambda (post) (+ post awesome)) posts)
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3500 on: November 16, 2012, 07:59:47 am »

Hello, I have not posted in this thread before.

I am also having issues with friction in a platformer. When I jump, I decrease friction to very low so you can "drift" through the air and not slow down (well, only slow down slightly). I also want a small degree of air-control, so you can somewhat influence how you are falling. But the combination of the two allows the player to jump from a high point and continue holding the move key in a direction, building up speed and getting super-fast (since lowering the friction has also increased the max speed) sometimes even clipping straight through the ground.

This seems reasonably accurate in real life, but for a game it doesnt seem right. My only solution is to manually enforce a top speed eg "if speed < max and trying_to_move: move_faster()".

Is this how it is generally done (it seems like an unelagent solution)?, or is my implementation of friction (it is a custom engine) just screwed up?
Logged
This is when I imagine the hilarity which may happen if certain things are glichy. Such as targeting your own body parts to eat.

You eat your own head
YOU HAVE BEEN STRUCK DOWN!

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3501 on: November 16, 2012, 08:06:34 am »

That's how I do it now, too, but the elegant solution is that the force exerted by (air)friction increases with the speed, so they should eventually cancel out when reaching the maximum speed (aka terminal velocity).

Edit: Oh, and welcome :)
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

Dutchling

  • Bay Watcher
  • Ridin' with Biden
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3502 on: November 17, 2012, 09:16:10 am »

(Python) Classes, how do they work?
When I do this:
Code: [Select]
class Point:

    def __init__(self, initX, initY):
        self.x = initX
        self.y = initY

    def getX(self):
        return self.x

    def getY(self):
        return self.y

def line_function(first,other):
        x_diff = other.x - first.x
        y_diff = other.y - first.y
        a = y_diff / x_diff
        b = first.y - a * first.x
        return (a,b,)

p = Point(0,17)
q = Point(5,27)

print(line_function(p,q))
print(q.getX)

It returns this:
Code: [Select]
(2.0, 17.0)
<bound method Point.getX of <__main__.Point object at 0x027E8F90>>

Why does the first print actually returns what I want it to return, while the second one just returns gibberish?
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3503 on: November 17, 2012, 09:57:17 am »

Oh god, Python. I know this language, but it is so fucking weird about how it handles everything that I always forget how to do anything.

I'm about 50% sure this won't fix your problem, but all my instincts are screaming at me that you should use print(q.getX()) instead. It looks like it is printing the methods toString.

Dutchling

  • Bay Watcher
  • Ridin' with Biden
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3504 on: November 17, 2012, 10:04:26 am »

That... actually worked.
I wonder why it didn't crash it in first place, considering doing that (no ''()'') with a normal function does crash.
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3505 on: November 17, 2012, 10:12:10 am »

Well if that worked, then I know exactly what was going wrong with it in the first place and why that fixed it.
You see functions are another attribute of a class, in a way, just like your X and Y attributes there. They are a little more touchy to use, but they can be passed around and such.
Now pretty much all things have some way to be converted to a string, and Python does this automatically when you try to print. As such, when you tried to print the method, that gibberish is what came out. It was giving you what you asked for, that being information about the method such as its name, the name of the class it is on, and the memory location of the object you were using. By using the parentheses, you forced the method to be called and return an integer, rather than using the method itself.


Think of it this way, you have a guy that gives you logs, and you throw them into a fire, except both you and the man are very dumb. You just grab what ever he gives you and throw it in. BUT nobody told the man to give you any logs, so you grabbed the man instead and threw him in. That is what the funny smell was.

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3506 on: November 17, 2012, 11:06:32 am »

Well if that worked, then I know exactly what was going wrong with it in the first place and why that fixed it.
You see functions are another attribute of a class, in a way, just like your X and Y attributes there. They are a little more touchy to use, but they can be passed around and such.
Now pretty much all things have some way to be converted to a string, and Python does this automatically when you try to print. As such, when you tried to print the method, that gibberish is what came out. It was giving you what you asked for, that being information about the method such as its name, the name of the class it is on, and the memory location of the object you were using. By using the parentheses, you forced the method to be called and return an integer, rather than using the method itself.


Think of it this way, you have a guy that gives you logs, and you throw them into a fire, except both you and the man are very dumb. You just grab what ever he gives you and throw it in. BUT nobody told the man to give you any logs, so you grabbed the man instead and threw him in. That is what the funny smell was.

That is a disturbingly accurate description of how Python does function pointers.

Dutchling

  • Bay Watcher
  • Ridin' with Biden
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3507 on: November 17, 2012, 11:09:22 am »

Max White, what is actually so 'fucking weird' about how Python does stuff?
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3508 on: November 17, 2012, 11:15:02 am »

Most languages are a little more strict about fitting square pegs in square holes, and round pegs in round holes. It is a bit more restrictive, but a lot safer. Python feels a little more like fitting play dough into holes to make the long shapes come out.

GreatJustice

  • Bay Watcher
  • ☭The adventure continues (refresh)☭
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #3509 on: November 17, 2012, 02:43:09 pm »

So I'm making a game with AS3, and I'm finding player controlled soundtracks to be annoying to work with.

I have four separate songs that the player(s) activate by pushing 1, 2, 3 or 4. However, so far as I can tell, I can't stop music that isn't playing yet. Therefore, I have had to make four separate booleans for each track (m1 for song 1, etc) and had to add something like 200 lines of code to allow for every possibility (checking if music 2 is running, turning off music 2 for music 3, etc). Is there a faster way to do this?
Logged
The person supporting regenerating health, when asked why you can see when shot in the eye justified it as 'you put on an eyepatch'. When asked what happens when you are then shot in the other eye, he said that you put an eyepatch on that eye. When asked how you'd be able to see, he said that your first eye would have healed by then.

Professional Bridge Toll Collector?
Pages: 1 ... 232 233 [234] 235 236 ... 796