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
The_Franz
Aug 8, 2003

Schmerm posted:

Here's a nonportable way I use to generate temporary breakpoints, that works only on x86:

code:
if (some condition)
{
    __asm int 3;
}
This generates a software interrupt using inline assembly and will make the debugger break there.

You can also use
code:
#include <assert.h>

...

assert(some condition);
for something that works on non-x86 platforms.

Adbot
ADBOT LOVES YOU

Baldbeard
Mar 26, 2011

Got another question for you guys.

So I had my game level load background objects, then the player, and then foreground objects. That way I can have the player, for example, walk behind trees on the bottom of the screen and walk in front of trees at the top of the screen. I realized I needed something more dynamic though, because if I have a tree in the center of the screen -- I want the player to be infront of it while he is below its center, and then behind it when he is above it.

The only solution I came up with is to re-add objects to the stage that the player interacts with, depending on his relative Y coord:

if(player.y > object.y)
level.addChild(object.y)
else
level.addChildAt(object.y, 0)

This works great as long as the object is alone. But if I have an arrangement of objects that are overlapping, they zip above and under each other as the player interacts with them.
So how do I change the objects arrangement relative to the player, without changing it's arrangement relative to other objects? Or should I be changing the players arrangement instead?

Maybe I'm coming at this all wrong. Actionscript's child system is kind of confusing.

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!

Baldbeard posted:

Got another question for you guys.
Most likely you want to sort the whole object list (other than background) by their bottom y coordinate. That way other moving things can also walk in front of and behind each other / trees / whatever.

Mug
Apr 26, 2005
I just discovered that Steam Overlay only works in OpenGL and DirectX. I use SDL.

Is it possible to just init OpenGL and put a transparent rectangle thing in-front of my game that doesn't do anything and then just go back to SDL for everything else? It sounds loving stupid, but it might be the easiest way to do this.

Jewel
May 2, 2009

Mug posted:

I just discovered that Steam Overlay only works in OpenGL and DirectX. I use SDL.

Is it possible to just init OpenGL and put a transparent rectangle thing in-front of my game that doesn't do anything and then just go back to SDL for everything else? It sounds loving stupid, but it might be the easiest way to do this.

Maybe? It'd add overhead though. A few SDL games on steam just don't offer overlays. Not the worst thing in the world if you have a windowed mode. People usually don't necessarily want to use the overlay in a fast paced game anyway.

The Gripper
Sep 14, 2004
i am winner

Mug posted:

I just discovered that Steam Overlay only works in OpenGL and DirectX. I use SDL.

Is it possible to just init OpenGL and put a transparent rectangle thing in-front of my game that doesn't do anything and then just go back to SDL for everything else? It sounds loving stupid, but it might be the easiest way to do this.
Have you actually tried it? SDL is just using OpenGL anyway (I think???? edit; oh maybe it just provides the SDL stuff and you can use OpenGL with it if you want, nevermind).

I just tested it out with Eversion on Steam which uses SDL and the overlay is fine.

The Gripper fucked around with this message at 10:24 on Jun 1, 2013

Mug
Apr 26, 2005
Doesn't work for me and the steam apps documentation says it only works on gl and directx. I'll fiddle more.

Verus
Jun 3, 2011

AUT INVENIAM VIAM AUT FACIAM
Speaking of SDL, I just wasted more hours than I'm willing to admit converting (the useful parts of) a mediocre SDL1.2 font/text rendering library to work with SDL2. On the bright side, at least I can finally appreciate how huge a leap forward SDL 2 is over previous versions. I mean, just look at the differences!
code:
SDL_SetColorKey(SDL_Surface surface, SDL_SRCCOLORKEY, keycolor);
versus the new SDL2 version:
code:
SDL_SetColorKey(SDL_Surface surface, SDL_TRUE, keycolor);
(the difference is that SDL_TRUE = 1 and SDL_SRCCOLORKEY = 4096)

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

Mug posted:

Doesn't work for me and the steam apps documentation says it only works on gl and directx. I'll fiddle more.

SDL2 uses OpenGL and DirectX under the hood, while 1.2 and previous used software acceleration. You'd have to force SDL 1.2 to do hardware acceleration and that could open up a can of worms for you.

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.

Mug posted:

I just discovered that Steam Overlay only works in OpenGL and DirectX. I use SDL.

Is it possible to just init OpenGL and put a transparent rectangle thing in-front of my game that doesn't do anything and then just go back to SDL for everything else? It sounds loving stupid, but it might be the easiest way to do this.
SDL1.2 should automatically use DirectX/OpenGL if your screen is a hardware surface (edit: apparently you have to use SDL_putenv("SDL_VIDEODRIVER=directx") on Windows but it's not guaranteed to give good results), but if that doesn't work, the "easiest" solution is to just enable OpenGL, render all your screen contents to a separate surface (instead of the SDL screen surface as it'll no longer work), and pass that on to OpenGL as a textured quad on the screen. This code sample should get you started.

It ignores all the advantages of hardware rendering, but at least it gives you an OpenGL output that can be picked up by Steam, capture software, etc. without having to rip your code apart (it's what we did for OpenXcom :v:). You might make it an option though because there always tends to be someone with lovely hardware that doesn't play well with OpenGL.

SupSuper fucked around with this message at 15:21 on Jun 1, 2013

Mug
Apr 26, 2005

SupSuper posted:

SDL1.2 should automatically use DirectX/OpenGL if your screen is a hardware surface (edit: apparently you have to use SDL_putenv("SDL_VIDEODRIVER=directx") on Windows but it's not guaranteed to give good results), but if that doesn't work, the "easiest" solution is to just enable OpenGL, render all your screen contents to a separate surface (instead of the SDL screen surface as it'll no longer work), and pass that on to OpenGL as a textured quad on the screen. This code sample should get you started.

It ignores all the advantages of hardware rendering, but at least it gives you an OpenGL output that can be picked up by Steam, capture software, etc. without having to rip your code apart (it's what we did for OpenXcom :v:). You might make it an option though because there always tends to be someone with lovely hardware that doesn't play well with OpenGL.

Doing the simple putenv didn't seem to work :(

I can do the latter, but I had a really limited understanding of how the backend SDL stuff is working so all I really managed to do was get the program to initialize a white screen then instantly close.

Maybe I'll leave it for now and get back to importany things.

syntaxrigger
Jul 7, 2011

Actually you owe me 6! But who's countin?

Waiting with bated breath for the game dev challenge thread to open up. Eager to get this ball rolling :)

thegasman2000
Feb 12, 2005
Update my TFLC log? BOLLOCKS!
/
:backtowork:

syntaxrigger posted:

Waiting with bated breath for the game dev challenge thread to open up. Eager to get this ball rolling :)

First year this year! Where does the thread go COBOL games or somewhere else?

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

syntaxrigger posted:

Waiting with bated breath for the game dev challenge thread to open up. Eager to get this ball rolling :)
Oh, poo poo, right, I guess I should stop being lazy on the couch and go type that up.

I slept in this morning. It was glorious.

syntaxrigger
Jul 7, 2011

Actually you owe me 6! But who's countin?

Thanks Shalinor! Sleeping in is the bees knees. Please put the link in this thread :)

Calipark
Feb 1, 2008

That's cool.

thegasman2000 posted:

First year this year! Where does the thread go COBOL games or somewhere else?

My first year as well, really excited to have an excuse to make a game that isn't a part of a 48 game jam.

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?
SA GameDev 8 is on

Raenir Salazar
Nov 5, 2010

College Slice
I was thinking based on suggestions in The Other Game Design thread to use Unity/Futile for 2D game design, would it be worth picking up any reference books for Unity and if so what would people recommend? My 'local' bookstore has Professional Unity and C#: Multi-Platform 3D Game Development, any good?

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

Raenir Salazar posted:

I was thinking based on suggestions in The Other Game Design thread to use Unity/Futile for 2D game design, would it be worth picking up any reference books for Unity and if so what would people recommend? My 'local' bookstore has Professional Unity and C#: Multi-Platform 3D Game Development, any good?

If you're looking to do Unity/Futile, a Unity book won't help much since all of your work will be in C# and not the Unity UI.

Dr. Dos
Aug 5, 2005

YAAAAAAAY!

xzzy posted:

Tomorrow is May 31st in the US. :ssh:

I swore the thread got posted a few weeks before the theme annoucement, but I just found the thread now so hooray.

seiken
Feb 7, 2005

hah ha ha
Not quite a finished dealio, but here's what I've been working on for the past few days.
linked because it seems chrome doesn't like big gifs or something?

The objective is real-time lighting. The traditional way of doing that in 2D would be to use a stencil-buffer method, that is, for each light, project all geometry away from the center point (to get the "shadows") and render that to the stencil buffer, and then re-render the scene. That method requires you to do at least two passes (including re-rendering the entire scene, usually) for every light.

In contrast, what I've come up with is an algorithm for directly computing the single polygon making up the light's visible area. It's like a more complicated version of the Graham scan, but still runs in O(n log n) (where n is the number of corners of world geometry on-screen, roughly). The cool thing is because we're calculating the lit area, rather than the shadows, the lighting draws are then additive instead of stencil-based, so I can render the entire lighting for arbitrarily many lights in just one draw call.

Edit: here's it running with a limited radius, which is maybe more obvious what's going on.
linked because it seems chrome doesn't like big gifs or something?
The best thing is this is perhaps the densest algorithm I've ever written and it basically worked the first time I ran it, although I had spent the past day or two thinking very carefully and drawing lots of diagrams

seiken fucked around with this message at 16:37 on Jun 2, 2013

Raenir Salazar
Nov 5, 2010

College Slice
So the mushroom is whats giving off the light right?

By a more complex Graham Scan you're kinda just basically going around corners of the local geometries until your back to where you started and voila, that's your lighting (and by extension, everything else is shadow?)?

e: Also for some reason that last picture freezes my browser to scroll over it.

seiken
Feb 7, 2005

hah ha ha

Raenir Salazar posted:

So the mushroom is whats giving off the light right?

By a more complex Graham Scan you're kinda just basically going around corners of the local geometries until your back to where you started and voila, that's your lighting (and by extension, everything else is shadow?)?

Yeah. The idea is pretty simple at a high-level, but trickier in implementation. Mostly to do everything efficiently so that you don't need to sort all the vertices in the world for every light. It's also completely algebraic (no trigonometric functions). It's also similar in many ways to an "angular" variant of the sweep line algorithm in polar coordinate space - you're basically forming the polygon defined by the furthest point for every angle that doesn't cross the back-side of any world geometry.

Now I need to write the shader that actually uses this to light the scene

e: you're right, it does for me as well, no idea why, I edited and linked them so as not to mess up everyone's chrome

seiken fucked around with this message at 16:24 on Jun 2, 2013

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!
In case anyone else is doing multiplayer stuff in HTML5, and also just because I want to rant about it, there's a horrible Chrome bug that it took me 3 days of debugging to figure out approximately what it is.

What I'm doing is using nginx's http_push_module to facilitate reasonably quick communication. On the client side, this is basically a long request with no (or long) timeout, and when it receives a message it initiates another long request. What I was originally doing is, during the XMLHttpRequest onreadystatechange handler, parsing the message and initiating a new XMLHttpRequest.

Approximately one time in four, this wouldn't work - the new request would exist, there would be a "pending" request in Chrome's debug network stuff, but it wouldn't receive any message. Obviously a nightmare to debug since it's hard to tell whether it's even server-side or client-side that the problem exists, and if client-side whether it's in the request-sending or receiving. But it didn't ever seem to fail on Firefox or IE.

Also, the communication is over SSL - Chrome's bug might not occur without that. Also, when I made a separate test page doing just this with the XMLHttpRequests, it worked fine, so I'm guessing there's some interaction with garbage collection or something involved in making it fail too. It's a pretty loving finicky bug.

I eventually managed to find what was actually happening using chrome://net-internals/#sockets - it turns out that when it works, a new socket is created, but when it fails, I think maybe it attempts to reuse the old socket just before it closes; there's a "socket closed" at the end of that socket in the net-internals page, but the closure never gets reported to the XMLHttpRequest handler so the javascript just sits there thinking it's pending forever. (As does the developer tools "network" tab!)

As a workaround, I moved the "make a new request" block of code into a setTimeout(RequestAgain,10) form, so now it works reliably enough in all the major browsers, but man that was bullshit to find, and that solution is bullshit too.

Coldrice
Jan 20, 2006


Alright I'm really feeling torn where to go with my next project. I just read about this on the cocos2d site;

http://www.apportable.com/

Appearantly a lot of people have been able to get their project working pretty quick with the free version.

I am really interested in cross platform.

I spent the past year learning objective-c and then cocos2d. i sorta started learning c++, then when unity gave free versions of ios/android I decided to learn c#/ unity. I just ported the absolute basics to get started to unity, and have actually gotten pretty pumped to release for pc/ios/android.

With this though, I can do android/ios projects seamlessly with a language I am very comfortable in. I can continue with cocos2d. I lose pc as a platform though. What should I do? Unity, or continue with cocos2d? I will be trying to make money off my new project

seiken
Feb 7, 2005

hah ha ha
Ok, here's the fruits of my labour. I linked it on another page so it doesn't break with the huge gif and I can blow it up to twice the size.

Lighting test!

Next up: normal mapping, so the tile details are lit consistently with the rest of the lighting.

seiken fucked around with this message at 22:17 on Jun 3, 2013

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

seiken posted:

Ok, here's the fruits of my labour. I linked it on another page so it doesn't break with the huge gif and I can blow it up to twice the size.

Lighting test!

Next up: normal mapping, so the tile details are lit consistently with the rest of the lighting.

That's really neato. I'll be disappointed if the final art isn't a mushroom on fire.

Kibbles n Shits
Apr 8, 2006

burgerpug.png


Fun Shoe
Can any resident XNA gurus tell me how I should be rendering my sprites so that they aren't incredibly blurry when I'm moving them around? I Googled around to no avail.

edit: vvv I forgot to mention that I tried that unsuccessfully, unless I hosed it up somehow. I'll try it again.

Kibbles n Shits fucked around with this message at 10:37 on Jun 4, 2013

seregrail7
Nov 3, 2006
From what I can remember I think you need to clamp the XY position to whole numbers.

Found this with a quick search: http://stackoverflow.com/questions/14821400/sprite-becomes-blurred

superh
Oct 10, 2007

Touching every treasure

DarthJeebus posted:

Can any resident XNA gurus tell me how I should be rendering my sprites so that they aren't incredibly blurry when I'm moving them around? I Googled around to no avail.

edit: vvv I forgot to mention that I tried that unsuccessfully, unless I hosed it up somehow. I'll try it again.

Are they just plopped on stage or are you rendering them off a camera? If its a camera you need to clamp that too.

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!
You can probably set some sort of filtering to "point filtering" to get non-blurred sprites. I don't know what the XNA way to do that is, but every other interface to DirectX/OpenGL does it.

Polio Vax Scene
Apr 5, 2009



Did you try changing the SamplerState? I believe you will want to use either SamplerState.PointWrap or SamplerState.PointClamp, depending on whether you care about repeating the texture and its dimensions are a power of 2.
If you're using SpriteBatch, you'll set it in SpriteBatch.Begin(), otherwise find your Game's GraphicsDevice.SamplerStates[0] and set that.

Also, one small thing you could try is rounding then adding .5 to x and y but this would indicate your viewport is off. Also as mentioned, check your camera to make sure it's coordinates are rounded as well.

Polio Vax Scene fucked around with this message at 15:38 on Jun 4, 2013

Raenir Salazar
Nov 5, 2010

College Slice

seiken posted:

Ok, here's the fruits of my labour. I linked it on another page so it doesn't break with the huge gif and I can blow it up to twice the size.

Lighting test!

Next up: normal mapping, so the tile details are lit consistently with the rest of the lighting.

:allears: Any chance will you be licensing this code or making it open source?

seiken
Feb 7, 2005

hah ha ha

Raenir Salazar posted:

:allears: Any chance will you be licensing this code or making it open source?

here you go, the license is the gently caress you licenses are boring license

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!

seiken posted:

here you go, the license is the gently caress you licenses are boring license
I would like this license to actually exist. But I can't imagine what it would say other than "gently caress you, licenses are boring", which wouldn't really convey any "I'm not going to sue you later for using my poo poo." I suppose you could add that too.

No Safe Word
Feb 26, 2005

roomforthetuna posted:

I would like this license to actually exist. But I can't imagine what it would say other than "gently caress you, licenses are boring", which wouldn't really convey any "I'm not going to sue you later for using my poo poo." I suppose you could add that too.

I mean there is the WTFPL which is kind of in that same spirit

Mata
Dec 23, 2003

seiken posted:

here you go, the license is the gently caress you licenses are boring license

Maybe I would share my code more often if it was this nice and commented...

DancingPenguin
Nov 27, 2012

I ish kakadu.
Could anyone give me a quick summary about ports?
I really suck at networking.
Basically my problem is that my game will not work on computers outside of my own network.
(I have changed the IP that the client should connect to from localhost to my actual IP, am I doing any silly errors by this?)

:ninja: edit: The person I have tried it with so far is just one person, so the error might just be with firewalls or such, but my question still stands.

DancingPenguin fucked around with this message at 22:44 on Jun 4, 2013

Workaday Wizard
Oct 23, 2009

by Pragmatica

seiken posted:

here you go, the license is the gently caress you licenses are boring license

Man! I wish my code was half as clean as yours. Thanks for sharing.

E: Why did you "typedef double world"? What does world mean in that context?

Workaday Wizard fucked around with this message at 22:56 on Jun 4, 2013

Adbot
ADBOT LOVES YOU

ambushsabre
Sep 1, 2009

It's...it's not shutting down!

DancingPenguin posted:

Could anyone give me a quick summary about ports?
I really suck at networking.
Basically my problem is that my game will not work on computers outside of my own network.
(I have changed the IP that the client should connect to from localhost to my actual IP, am I doing any silly errors by this?)

:ninja: edit: The person I have tried it with so far is just one person, so the error might just be with firewalls or such, but my question still stands.

On your router (assuming you're hosting), the port that you're using needs to be open. Make sure your ip isn't changing when you give them the build (this should really be something they as a client should be able to change, but I understand hard-coding it for testing purposes). cmyip.com is good for that. I'm also assuming everything works correctly on localhost, if it does work correctly connecting to 127.0.0.1, then it's a router port-forwarding issue on the host.

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