Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Paniolo
Oct 9, 2007

Heads will roll.

Contero posted:

What's the accepted way to handle the mouse for things like first person camera where you can potentially scroll forever? This is in straight win32 if it matters. The way I used to do it was:

* Hide cursor, move cursor to center of screen.

* On each frame, measure distance between cursor position and center of screen, that is my mouse dx,dy for the frame. Then move cursor back to the center.

Are there any potential problems with this? Is there an easier way to do this in windows? I'm trying to avoid direct input if possible.

That's the best way to do it.

Adbot
ADBOT LOVES YOU

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

Contero posted:

What's the accepted way to handle the mouse for things like first person camera where you can potentially scroll forever? This is in straight win32 if it matters. The way I used to do it was:

* Hide cursor, move cursor to center of screen.

* On each frame, measure distance between cursor position and center of screen, that is my mouse dx,dy for the frame. Then move cursor back to the center.

Are there any potential problems with this? Is there an easier way to do this in windows? I'm trying to avoid direct input if possible.

Make sure you also turn off the mouse centering when the game window loses focus so Alt+tabbing over to another application doesn't leave the mouse pointer obnoxiously pinned to one point on the screen.

A certain Microsoft MVP likes to release code samples that don't un-pin the mouse and don't have any keyboard shortcuts to exit the game. Once you start running his stuff you either have to figure out how to kill the process using only keyboard commands or just say fuckit and reboot.

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

PDP-1 posted:

Make sure you also turn off the mouse centering when the game window loses focus so Alt+tabbing over to another application doesn't leave the mouse pointer obnoxiously pinned to one point on the screen.
To add to this, you also want to:

- Free the mouse when in menu mode (ie. after hitting escape), for easy windowed use. Hit escape, menu pops up, you're free to move the mouse out of the window, whatever, click "resume", re-hide and re-center the mouse.
- Have loss of focus result in an auto escape press / automatically enter menu mode. Does double duty as a mouse free and an auto-pause during unexpected popups.
- Store the mouse position previous to freezing/hiding it. Restore that position when unfreezing the mouse.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!
I'm melting my brain with this, so hopefully I can get a little help.

The situation - I have two skeletons. One is tied into a physics system and the other is not. I want the one in the physics system to try to mimic the one that is not, but because it's in the physics system obviously I can't just update its position to the same as the other's position, because I might be causing physics objects to overlap and such, so the physics skeleton can only be adjusted by changing velocities of the rigidbodies that are attached to it.

Initially I just applied linear velocities to the rigidbodies, pushing them towards the target position, which mostly worked (the skeleton joints held it together and essentially turned those forces into bone rotations) but it tended to make for somewhat jerky motion, and could get some nasty locking where joints would be twisted and the positioning force wouldn't do anything to untwist them. It was kind of a lazy kludge anyway, so I figure now I want to do similar but with angular velocities.

The other catch is that I want to have a cap on how fast the physics skeleton can accelerate.

I'm doing this in Unity, so what I've found is that I can get an angular velocity for any given bone, which comes in the form of a Vector3 - I gather that that's the axis of rotation and its magnitude is the angular velocity. I can also get a Quaternion that represents the rotation I want the bone to go through to be in its target position.

Simplifying the problem slightly, I don't want to cap *deceleration*. While that's slightly more complicated in that I have to figure out what's a decel, it makes it much easier to stop in the target position, because I can just stop when it's reached/passed rather than having to slow down before I get there, so I avoid the Newtonian spring effect.

I figure the angular velocity (when reading it) can be treated as if it's around the joint, because the skeleton will have enforced that, and when I'm applying a change I can apply it using AddTorque, around the joint, so those aspects aren't a worry.

I can convert Quaternions and, probably, that weird Vector3, to and from angle-and-axis values.

Maybe I can treat 'sideways' acceleration similar to deceleration, in which case perhaps I can just treat the magnitude as a linear value that I apply acceleration or deceleration to, and replace the axis of rotation wholesale with the axis that rotates towards the target position. So that gets me a value for the angular velocity after adjustment...

But I'd still need to figure out the velocity-change-torque required to go from angular velocity A to angular velocity B. How would I go about figuring that? (If I didn't do it with a torque but with actually changing the velocity then I'd still be effectively torquing around the center of mass instead of around the joint.)

Unity gives me an AddTorque(Vector3, ForceMode.VelocityChange) so I don't need to worry about applying an acceleration over time, but I have no idea how to calculate, essentially, "angularVelA - angularVelB". It's not something as simple as doing that with the Vector3 values is it?

roomforthetuna fucked around with this message at 05:26 on Feb 26, 2012

Shameproof
Mar 23, 2011

I made a little thingy that's like Slime Volleyball, I'm going to keep working to turn it into something I think will be really cool. If you guys have any critiques I'd love to hear them. Currently it only works with a gamepad.
So far I've only found one bug, where if the ball hits the slime at a really acute angle, it will "orbit" around it. That's because it collides again and again several frames in a row; it shouldn't be too hard to fix.

http://www.mediafire.com/?htboot3hnafy33t

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

roomforthetuna posted:

The situation - I have two skeletons. One is tied into a physics system and the other is not.
What's this for? I'm having a hard time telling what you're trying to do and, in turn, if this is even an ideal approach.

roomforthetuna posted:

but I have no idea how to calculate, essentially, "angularVelA - angularVelB". It's not something as simple as doing that with the Vector3 values is it?
Yes, it is.

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

Shameproof posted:

I made a little thingy that's like Slime Volleyball, I'm going to keep working to turn it into something I think will be really cool. If you guys have any critiques I'd love to hear them. Currently it only works with a gamepad.
So far I've only found one bug, where if the ball hits the slime at a really acute angle, it will "orbit" around it. That's because it collides again and again several frames in a row; it shouldn't be too hard to fix.

http://www.mediafire.com/?htboot3hnafy33t

I didn't get the orbit bug, but I noticed that if you stay motionless at the beginning of the game and only jump when the ball is about to collide with the player character you can eventually accelerate the ball so much that it flies off the top of the screen.

Other than that it seemed to work fine!


e:

roomforthetuna posted:

Unity gives me an AddTorque(Vector3, ForceMode.VelocityChange) so I don't need to worry about applying an acceleration over time, but I have no idea how to calculate, essentially, "angularVelA - angularVelB". It's not something as simple as doing that with the Vector3 values is it?

If you know the angle that you're at and the angle you want to be at in time dt you can apply an impulse torque that will move you there. Check my math on this, but I got

impulseTorque = I/dt*((targetAngle - currentAngle)/dt - currentAngularVelocity)

where I is the moment of inertia.

This will move you to the position you want to be in, but it leaves the angular velocity uncontrolled so you'll get the spring motion problem you mentioned when you want to stop moving. Unfortunately I don't think there's a direct physical solution to that since you are trying to control two variables (position and velocity) with one setting (impulse torque) and that leads to an over-constrained system that only has a solution for the trivial case where nothing is moving.

You might be able to patch around that situation by adding a non-physical extra condition - if your current angle is within some epsilon of your target angle kill the angular velocity to stop moving. If your angles are 'close enough' apply something like

impulseTorque = -currentAngularVelocity * I / dt

to make the angular velocity go to zero.

The more fundamental problem is that you're trying to make a relatively constrained system (skeleton with physics) act like an unconstrained system (skeleton with no physics) and that is always going to be difficult. It'd be better to try to think of another way to go about solving the problem that you really want to solve which seems to be 'make skeleton A mimic the motions of skeleton B'.

PDP-1 fucked around with this message at 16:57 on Feb 26, 2012

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

OneEightHundred posted:

What's this for? I'm having a hard time telling what you're trying to do and, in turn, if this is even an ideal approach.
Essentially I'm wanting to mix a pre-recorded animated skeleton into a physics world. I don't want the animation to be all "irresistible force" or "immovable object" to the rest of the world as is standard with, say, Kinect input, nor the converse "doesn't really interact with the world other than maybe to have the character as a whole blocked by it" that's the usual way of doing things in RPG and FPS contexts. The capping acceleration is (part of) my way of preventing the player-character from exerting unreasonable forces on the world - I don't want one inch punches.

I'm trying to compose an entire game based on what Lowtax calls rear end in a top hat physics, with enough restrictions on what you can do to make it so it still presents a challenge. (Thinking about it, I guess Katamari Damacy was also kind of an rear end in a top hat physics game.)

I too don't know whether this way is the best way of doing it, and I actually had reasonable results already with linear velocities or even with attaching springs between the immovable-untouchable target skeleton and the physics skeleton, but I think angles will give me better results, both in terms of not locking up, and because my linear system capped the acceleration of each part, so a hand couldn't speed up much faster than an elbow, whereas with angles the shoulder-rotation moving the elbow and the elbow-rotation moving the hand will both contribute to the hand's speed, so it will effectively get two (or more) caps worth of acceleration.

Thanks for your help (and yours, PDP-1). And mine as well, I'd been struggling with it for a while and just writing it out as a question got me several steps closer.

Edit: to some extent think Ragdoll Kung-Fu in 3D. I don't know if Ragdoll has an invisible skeleton behind the scenes, but I'm fairly sure it has a target position for idle standing that it moves the physics body towards, and the mouse pointer provides overriding target limb positions. That my "target position" is also a skeleton isn't really all that relevant to the underlying goals.

roomforthetuna fucked around with this message at 17:41 on Feb 26, 2012

brian
Sep 11, 2001
I obtained this title through beard tax.

The guys at Flashbang did a game that did the same thing called Minotaur China Shop in Unity a couple of years back, I believe somewhere on the tech blog there's some explanation but as you can see from the game it's a really hard thing to do and still have the character remain upright and all together.

I mean there's a reason it's not done outside of fringe cases, it's very hard to make stable enough for anything other than a gimmick (not that there's anything wrong with that gimmick).

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!
Yeah, I have an adequate working solution for the upright, together and on-the-floor problems - it's basically "not going too overboard with the physics." I'm not worried about cheating a little and applying magical forces out of nowhere for balancing, so that makes it a lot easier. The torso, in my model, is a magical flying spaceship with a 'descend' control if the feet aren't on the floor, an 'ascend' control if the feet are too much on the floor, and a 'move laterally' control if it's not centered over the midpoint of the feet. And for rotation it turns to match the target skeleton, applying that torque also magically out of nowhere.

Edit: it's not really quite that simple, so having the character stick both its feet out like sitting on the floor won't make it magically fly forwards or anything.

roomforthetuna fucked around with this message at 18:35 on Feb 26, 2012

Paniolo
Oct 9, 2007

Heads will roll.
Can you designate some bones are physics-driven and others as animation-driven? That's how most engines mix the two these days. Trying to interpret canned animations as physical forces just doesn't work well in anything other than trivial cases.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Paniolo posted:

Can you designate some bones are physics-driven and others as animation-driven? That's how most engines mix the two these days. Trying to interpret canned animations as physical forces just doesn't work well in anything other than trivial cases.
Not really, the whole point is that the animation is going to interact with physics objects - that minotaur game is a pretty good showing of the kind of thing I'm going for, except that theirs feels like it's gone a bit more "irresistible force" about it.

As I say, I'm not so crazy as to try to do the whole thing with nothing but realistic physical forces - I'm not going to be trying to have my skeleton stand up and balance itself using only pressure against the ground or anything. And I already had it performing almost what I want by applying just simple linear velocity adjustments, so I'm pretty sure the concept is workable.

I'm so uncaring of the precise realism that I don't even have gravity applied to any part of the player-character.

Which is to say, yeah, I realize trying to interpret canned animations as physical forces doesn't work, so it's not what I'm doing. :) I'm just trying to approximate canned animations, by setting velocities, which is significantly less problematic. Still a significant pain in the rear end, obviously, but worth the effort since it's the very core mechanic of my game.

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?
Another game worth looking into is Octodad. It really nails the whole "movement is awkward because it's physical but that's the charm" thing.

It's driving a skeleton based on input as opposed to animation, but the problem space is still quite related.

Shameproof
Mar 23, 2011

PDP-1 posted:

I didn't get the orbit bug, but I noticed that if you stay motionless at the beginning of the game and only jump when the ball is about to collide with the player character you can eventually accelerate the ball so much that it flies off the top of the screen.

Found it and destroyed it!

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Shalinor posted:

Another game worth looking into is Octodad. It really nails the whole "movement is awkward because it's physical but that's the charm" thing.

It's driving a skeleton based on input as opposed to animation, but the problem space is still quite related.
Yeah, mine isn't really based on animation either, but for explaining what's happening purposes it's closer to that than it is to, say, Ragdoll Kung Fu's dragging input - the input is (by the time it gets into play) locked to skeletal rotations just like an animation would be. Getting Octodad to take a look now.

Edit: Yeah, Octodad's results are pretty similar to what I had with the linear "pulling" velocities, but Octodad's a bit messier and avoided locking joints by having bendy limbs that are happy to pass through each other and twist as much as they like. As you say, works okay for what they were going for.

roomforthetuna fucked around with this message at 01:21 on Feb 27, 2012

HauntedRobot
Jun 22, 2002

an excellent mod
a simple map to my heart
now give me tilt shift
My new years resolution was to go beyond my little OpenGL toy projects and build a game engine. Just did some very basic, "duh" optimisations, bringing my OpenGL code screaming into the early-to-mid-00s state of the art. And, well...

code:
           %   cumulative   self              self     total           
          time   seconds   seconds    calls  ms/call  ms/call  name 
Before:  29.98      2.59     2.59     1042      2.49    5.23  Layer_Game::Render(SceneGame*)
After:    1.28      0.83     0.02     1005     0.02     0.02  Layer_Game::Render(SceneGame*)

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

roomforthetuna posted:

Essentially I'm wanting to mix a pre-recorded animated skeleton into a physics world.
This has been a very elusive thing that big studios have been prepared to shell a lot of money out for. It's a Big Problem and there is no simple answer to it.

There are a lot of problems with it that you need to answer, like what happens if a movement gets blocked, what do you do next frame? Do you try producing enough force to bring the skeleton to where the frame says it should be, or just the difference between the frames? If a movement is blocked for several frames, the first might give you wild snaps when a blocked part hits an object, the second might contort your model out of shape.

One thing that does work reasonably well is kick-outs: Essentially, skeletal animations would be unstoppable, but the difference between frames will cause force transfers to objects they collide with which physics engines are GENERALLY good enough to handle well.

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

OneEightHundred posted:

One thing that does work reasonably well is kick-outs: Essentially, skeletal animations would be unstoppable, but the difference between frames will cause force transfers to objects they collide with which physics engines are GENERALLY good enough to handle well.
This works, but not so much for rear end in a top hat physics like roomforthetuna is going for. 1-way collisions of that sort make the entire world feel like it's made of styrofoam.

I think he's on to the right track with going the other way, and thinking of the skeleton as a goal target, with the bones accelerating toward the target up to a max force. The movement will be a lot spongier, granted, but definitely kinetic and fun-feeling as far as collision interactions go.

You just need to make sure you're not using this to actually stand your guy up, or expecting it to be in any way a sensible pose that is eventually adopted. If you try and marry all of this to a walking and balance algorithm as well... woof, good luck there.

Shalinor fucked around with this message at 22:50 on Feb 27, 2012

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Shalinor posted:

This works, but not so much for rear end in a top hat physics like roomforthetuna is going for. 1-way collisions of that sort make the entire world feel like it's made of styrofoam.

I think he's on to the right track with going the other way, and thinking of the skeleton as a goal target, with the bones accelerating toward the target up to a max force. The movement will be a lot spongier, granted, but definitely kinetic and fun-feeling as far as collision interactions go.

You just need to make sure you're not using this to actually stand your guy up, or expecting it to be in any way a sensible pose that is eventually adopted. If you try and marry all of this to a walking and balance algorithm as well... woof, good luck there.
Yeah, this is exactly what I'm aiming for (and almost achieving right now). There is kind of a walking algorithm, but only in much the same way that Octodad has a walking algorithm, it's certainly not trying to balance. (Actually I think it's even essentially the same as Octodad's walking algorithm - a raised foot can move freely, a down foot is glued in place.)

The spongy movement isn't a big issue, it largely fits with the game's setting and concept anyway, and I get at least semi-reasonable poses throughout because the skeleton I'm dragging around is a ragdoll held together with limiting joints - so if the control forces try to push it into a hideous impossible position, the joints resist those forces.

As for the question of being blocked - if you're moving fast enough then it'll play out as an impact on the blocking object, and if you're moving too slow then the object will stop your motion and you'll be left just gently pressing on it (unless it's light/weak enough to be moved by gently pressing). That part was already working pretty well with the old linear-pulling-skeleton method too. I still need to work on the interface to enable stepping backwards to take a better run-up, but the concept was working decently.

Semi-relatedly, how do you get past the Octodad room with the button that only temporarily opens a door? I wasn't able to run fast enough to make it even half way before the door was closed.

roomforthetuna fucked around with this message at 01:31 on Feb 28, 2012

Pfhreak
Jan 30, 2004

Frog Blast The Vent Core!
How does one draw lasers? I understand how to do traditional bullets, but I don't think I can leverage the same techniques to create something like Jamestown's laser. Unfortunately, I'm having some trouble googling for the techniques to efficiently and properly draw this effect. I'm guessing I'm too close to the problem and trying to overcomplicate it.

Svampson
Jul 29, 2006

Same.

Pfhreak posted:

How does one draw lasers? I understand how to do traditional bullets, but I don't think I can leverage the same techniques to create something like Jamestown's laser. Unfortunately, I'm having some trouble googling for the techniques to efficiently and properly draw this effect. I'm guessing I'm too close to the problem and trying to overcomplicate it.

This might be a terrible way to do it, but the way I usually do it is having the laser be one long sprite and simply have it follow the ship that's firing it

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

Svampson posted:

This might be a terrible way to do it, but the way I usually do it is simply having the laser be one long sprite and simply have it follow the ship that's firing it
Seconding this. I believe the typical approach is to just make a tiling texture and apply it to a very long quad. One axis of the texture doesn't tile, and has the soft / laser'y edges, and the other axis tiles down the length of the quad to give it a bit of fine detail and noise.

Some people even skip on the tiling, and make the laser just be a stretched texture. It works fine if your lasers are a pure center-to-edge gradient with no noise whatsoever. This is more common the more old-school you go, seeing as how tiling texture mappers weren't always at your easy disposal.

EDIT: Oh, right, and in 3D, you can do that, but in an X pattern with two 2-sided quads (and you might do those additively as opposed to blended). You can also do the calc of a plane fixed at two ends / figure out the closest to camera facing orientation, and leave it at 1 plane that might vary in thickness slightly depending on view angle.



EDIT: ... but while we're on the subject, I WOULD like to know how on earth you do proper (procedural) ropes and lightning. I know how I'd do it with a fixed mesh (make a skinned mesh with a ton of bones), but my approach would either leave obvious kinks in the rope/lightning or have so many bones as to be absurd. Even HL2 did perfect power line ropes, so surely there's a cheaper way of handling it.

I can imagine additive particle approaches, but again, it'd have issues. The lightning wouldn't look anything like lightning color-wise, and your rope would be a blurry indistinct mess.

EDIT: VV Oooooh. Now that's neat.

Shalinor fucked around with this message at 18:39 on Feb 29, 2012

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Shalinor posted:

Seconding this. I believe the typical approach is to just make a tiling texture and apply it to a very long quad. One axis of the texture doesn't tile, and has the soft / laser'y edges, and the other axis tiles down the length of the quad to give it a bit of fine detail and noise.

Some people even skip on the tiling, and make the laser just be a stretched texture. It works fine if your lasers are a pure center-to-edge gradient with no noise whatsoever. This is more common the more old-school you go, seeing as how tiling texture mappers weren't always at your easy disposal.
Another semi-common approach is to use a 4-quad star-shaped projection, I think UT2003's link gun does this. It has less warping near the camera but it's largely limited to beams that are bright at the core.

One thing that I think is pretty promising is the raytraced cylinders that Eve is now using for engine trails, which solves the problems of weird end behavior and is a bit more accurate, but texturing them would be difficult.

e: Don't do that unless you have a thick beam.

OneEightHundred fucked around with this message at 18:49 on Feb 29, 2012

Pfhreak
Jan 30, 2004

Frog Blast The Vent Core!

Shalinor posted:

Seconding this. I believe the typical approach is to just make a tiling texture and apply it to a very long quad. One axis of the texture doesn't tile, and has the soft / laser'y edges, and the other axis tiles down the length of the quad to give it a bit of fine detail and noise.

Some people even skip on the tiling, and make the laser just be a stretched texture. It works fine if your lasers are a pure center-to-edge gradient with no noise whatsoever. This is more common the more old-school you go, seeing as how tiling texture mappers weren't always at your easy disposal.

EDIT: Oh, right, and in 3D, you can do that, but in an X pattern with two 2-sided quads (and you might do those additively as opposed to blended). You can also do the calc of a plane fixed at two ends / figure out the closest to camera facing orientation, and leave it at 1 plane that might vary in thickness slightly depending on view angle.



EDIT: ... but while we're on the subject, I WOULD like to know how on earth you do proper (procedural) ropes and lightning. I know how I'd do it with a fixed mesh (make a skinned mesh with a ton of bones), but my approach would either leave obvious kinks in the rope/lightning or have so many bones as to be absurd. Even HL2 did perfect power line ropes, so surely there's a cheaper way of handling it.

I can imagine additive particle approaches, but again, it'd have issues. The lightning wouldn't look anything like lightning color-wise, and your rope would be a blurry indistinct mess.


If I remember correctly, the power lines in HL2 were more or less billboarded quads that had only a solid diffuse color. They were cheap enough to render (and far enough from the camera) that just had a number of segments. If they get hit with big forces you can definitely see the kinks in them. (Or if you fly up close to them, the trick sort of falls apart.) It's one of those 'just real enough for your brain to fill in the details' elements.

Thanks for the laser tips, don't know why that didn't occur to me immediately. It's too bad that canvas element doesn't allow you to tile textures as far as I can tell. Multiple calls to drawImage() here I come.

Pfhreak fucked around with this message at 20:51 on Feb 29, 2012

a lovely poster
Aug 5, 2011

by Pipski
So I'm working on prototyping a new project using Love2D (cool library if anyone is looking for something new to learn - https://love2d.org/) using overlapping sprites and I was wondering how exactly I'm supposed to make the sheets transparent. All of the tiles display correctly but I'm not sure how to import tiles as transparent. For example, when I display the player's tile on top of a floor tile the background from the sprite sheet is still present. I know there has to be an easy way for me to ignore the background color when importing the image (Blendmode? I'm not too familiar with these things) but I'm not even sure how exactly to phrase the question, which is making finding an answer difficult.

HiriseSoftware
Dec 3, 2004

Two tips for the wise:
1. Buy an AK-97 assault rifle.
2. If there's someone hanging around your neighborhood you don't know, shoot him.

a lovely poster posted:

So I'm working on prototyping a new project using Love2D (cool library if anyone is looking for something new to learn - https://love2d.org/) using overlapping sprites and I was wondering how exactly I'm supposed to make the sheets transparent. All of the tiles display correctly but I'm not sure how to import tiles as transparent. For example, when I display the player's tile on top of a floor tile the background from the sprite sheet is still present. I know there has to be an easy way for me to ignore the background color when importing the image (Blendmode? I'm not too familiar with these things) but I'm not even sure how exactly to phrase the question, which is making finding an answer difficult.

Your sprite sheets should have an alpha channel where pixels that are the "background" are marked as transparent. Love's default blend mode is alpha, so as long as your sheets are set up correctly it should work.

dizzywhip
Dec 23, 2005

Pfhreak posted:

Thanks for the laser tips, don't know why that didn't occur to me immediately. It's too bad that canvas element doesn't allow you to tile textures as far as I can tell. Multiple calls to drawImage() here I come.

For a simple laser you could just use canvas's shape-drawing calls. You can just draw a long rectangle at whatever angle you want, maybe with a gradient or with a second, thinner rectangle in the middle to give it some depth. Then you could have the color flash and maybe generate some floaty particles around it to make it look even better.

h_double
Jul 27, 2001
Anybody looking for any music / audio for their games? I'm looking for new projects and am fluent in styles in the direction of rock, techno/electronic, and ambient (also some sound FX/sound design).


Guitar type instrumental

Trance/electronic beats (I made this for the soundtrack of a zombie movie).


There's a bunch of other stuff in various styles on my Soundcloud so hit me up on SA or at discolingua@gmail.com if anything piques your interest.

field balm
Feb 5, 2012

Gordon Cole posted:

For a simple laser you could just use canvas's shape-drawing calls. You can just draw a long rectangle at whatever angle you want, maybe with a gradient or with a second, thinner rectangle in the middle to give it some depth. Then you could have the color flash and maybe generate some floaty particles around it to make it look even better.

I've been working on a game in canvas lately using something like this for tiling:

bg=new Image();
bg.src='grid.png'
ctx.fillStyle = ctx.createPattern(bg, "repeat");

then drawing whatever shape you want filled with this. The above is used for filling my level editor with a tile grid. Should work great for a 2d laser!

Pfhreak
Jan 30, 2004

Frog Blast The Vent Core!

field balm posted:

I've been working on a game in canvas lately using something like this for tiling:

bg=new Image();
bg.src='grid.png'
ctx.fillStyle = ctx.createPattern(bg, "repeat");

then drawing whatever shape you want filled with this. The above is used for filling my level editor with a tile grid. Should work great for a 2d laser!

You are a good person.

RoboCicero
Oct 22, 2009

"I'm sick and tired of reading these posts!"
For those working with XNA, someone said that they figured out how to directly render the game into a video by pulling the buffers out instead of doing a middle-ware solution like FRAPS. Was that just my wishful thinking or is there some kind of code block I can put in to enable/disable it?

I have about 20 days to make a game for a class in XNA (It's advanced computer graphics, go figure) and I thought it'd be neat to do a day by day progress log.

Pfhreak
Jan 30, 2004

Frog Blast The Vent Core!

RoboCicero posted:

For those working with XNA, someone said that they figured out how to directly render the game into a video by pulling the buffers out instead of doing a middle-ware solution like FRAPS. Was that just my wishful thinking or is there some kind of code block I can put in to enable/disable it?

I have about 20 days to make a game for a class in XNA (It's advanced computer graphics, go figure) and I thought it'd be neat to do a day by day progress log.

It should definitely be doable. I've rendered to animated gifs before. I want to say I used RenderTarget to change where I drew to. The rendertarget can be cast to a Texture2D, which has methods to get the pixel data out (which I then saved as frames in a folder).

This was for a discrete stepped project, however, so I didn't need to be able to save the frames real-time. There's probably a faster way to do it.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
So how are people doing environmental collision detection? Say I have this room:



How can I best make sure that no one leaves the room? Right now it's just a single sprite for the room with bandit and skeleton in it so they can really go anywhere including outside.

For the main game, I'm thinking about strange shaped hallways and stuff and wondering how I'm going to have collision detection for those walls without having a million rectangle objects? How are you guys creating metroidvania environments and handling and modeling the collisions with walls, floors, and ceilings?

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Have some way of determining whether a tile in tile coordinates is "solid"- you can have a separate collision map or perhaps a lookup table from tiles to terrain types. Then, convert a series of "test points" representing a bounding box for your sprites into tile coordinates and look up the collision status of the corresponding tile. If any of the test points are colliding, your sprite is hitting a wall. Sometimes just four test points on the corners of your sprite (or their footprint, given perspective) is sufficient, other times you need more- it depends on the ratio between sprite size and tile size. Too few test points and you'll be able to slide through gaps in tiles or fit tiles between your test points.

You can get really complicated if you want to support partially collidable tiles, one-way platforms and smooth out the apparent collision volume on tile corners (as Zelda does), but that's the gist of it.

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.
Check out the XNA Platformer Starter Kit, it uses a tile-based structure where each tile has a settable collision behavior. The documentation is pretty decent, the last time I looked at it the code base was a bit messy but manageable.

Incidentally, this was the codebase that we used to bring Crimson Haze: The Legend of Fartsword to life back in the day. This massively multi-platform offline role playing game was designed by SA's own Bestow and became a goon project of sorts. Maybe not the goon project Bestow had in mind, but a goon project that produced a working game nonetheless.

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
Thanks for the suggestions guys. I was also looking into the farseer physics engine since I can union the tiles together into a single polygon. I think this might be a possible solution since I'll be using harringbone wang tiles and I can pregenerate the wall polygons for each tile.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
I'd definitely try it before I worried about it too much, but don't you think colliding against complex polygons (the union of solid tiles in a room) could get kinda expensive? At minimum, the cost would scale with the amount of detail in a room, which means it could be one of those issues that sneak past early testing and bite you while you're worrying about level design later. Probably not a huge issue, but worth thinking about.

devilmouse
Mar 26, 2004

It's just like real life.
Once again, I struggle as to which game thread to post this in, but this seems most relevant!

https://store.unity3d.com/

Unity 3d Mobile Basic is up for free download until April 8th.

mewse
May 2, 2006

devilmouse posted:

Once again, I struggle as to which game thread to post this in, but this seems most relevant!

https://store.unity3d.com/

Unity 3d Mobile Basic is up for free download until April 8th.

500 - Internal Server Error :razz:

Adbot
ADBOT LOVES YOU

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

mewse posted:

500 - Internal Server Error :razz:

Me too. They'll probably be slammed until it ends. :qq:

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply