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
KoRMaK
Jul 31, 2012





I wanted to make what looks like gravity wells and other gravity induced distortion to my background grid and this is how it's turned out. I'm using newton's law of gravitational attraction to loop through each pixel and find the forces that would be acting on it. Then I had to add a way to blend the neutral color into the distorted colors, otherwise I would get very noticeable noncontinuous jumps. What I didn't realize until I looked it up this morning (after already getting an equation in place but some weird artifacting lead me to search out reasons why), did I realize I had independently come up with the equation for Alpha blending! It turns out that I had typo-d the variable that is suppose to be containing my lerp value (which acts as the alpha value) with another, similarly name variable, meaning that my logic was sound. So that was pretty cool! What a relief!

I think I want to make a big effort post with all my code to do this but haven't committed to the idea yet.

Adbot
ADBOT LOVES YOU

Lord Chumley
May 14, 2007

Embrace your destiny.
Are there any guides on how to set up SDL 2.0 properly in Code Blocks? Google is not helping me at all and turning up older versions.

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.

Lord Chumley posted:

Are there any guides on how to set up SDL 2.0 properly in Code Blocks? Google is not helping me at all and turning up older versions.
I would assume the process is the same as for SDL 1.2 (download MinGW32 binaries, set up include and library paths) but replace any "SDLxxx.lib" with "SDL2xxx.lib" and "#include <SDL/SDL.h>" with "#include <SDL2/SDL.h>".

Edit: This website covers setting up SDL 2.0 if you can make the leap from MinGW32 to Code::Blocks.

SupSuper fucked around with this message at 03:29 on Sep 4, 2013

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

ahmeni posted:

It was my understanding that the Metanet N-style was built for platforming with collisions involving arbitrary polygons via the Separating Axis Theorem, which seemed like too big of a hurdle to tackle for the simple route I wanted to go with just 1:1 and maybe 1:2 slopes.

Well, that's one of the methods, but the collision detection and response parts based on projecting out of a colliding axis should still be relevant.

Lord Chumley
May 14, 2007

Embrace your destiny.

SupSuper posted:

Edit: This website covers setting up SDL 2.0 if you can make the leap from MinGW32 to Code::Blocks.

There's nothing on there about Codeblocks. :(

Thanks for looking around though.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

xgalaxy posted:

You gotta admit its one of the weirder things about the language though, that you can create a property to a struct.
It's confusing if you aren't paying attention or aren't familiar with how C# handles class vs struct. They need better compiler warnings on it if nothing else.
The problem is that C# access control is done in terms of the object storing the value, rather than the mutability of the value itself, so it doesn't get to yell at you for trying to modify a returned temporary like C++ can do.

The simplest pattern for avoiding the whole mess is to treat structs as immutable values, similar to how strings already are.

ZombieApostate posted:

If you happen to dump a fnt file in the same format as BMFont (or a subset of it), I will love you.
I was just going to dump a glyph table and a kerning pair table as CSV. Do you need something close to that format in particular, or just something easy to parse?

ZombieApostate
Mar 13, 2011
Sorry, I didn't read your post.

I'm too busy replying to what I wish you said

:allears:

OneEightHundred posted:

I was just going to dump a glyph table and a kerning pair table as CSV. Do you need something close to that format in particular, or just something easy to parse?

I only mentioned it because that's what UIToolkit uses, but I can just write something to convert whatever you output if that's too much trouble. In related news, apparently Hiero also outputs the same format and puts out much nicer looking bitmaps, although it's pretty slow and crashy. It will at least do the job.

Edit2: gently caress, I shouldn't be working at 2AM... using num instead of i.

ZombieApostate fucked around with this message at 07:01 on Sep 4, 2013

Zizi
Jan 7, 2010

OneEightHundred posted:

I was just going to dump a glyph table and a kerning pair table as CSV. Do you need something close to that format in particular, or just something easy to parse?

ZombieApostate posted:

I only mentioned it because that's what UIToolkit uses, but I can just write something to convert whatever you output if that's too much trouble. In related news, apparently Hiero also outputs the same format and puts out much nicer looking bitmaps, although it's pretty slow and crashy. It will at least do the job.

Edit2: gently caress, I shouldn't be working at 2AM... using num instead of i.

NGUI also uses BMFont(if you aren't using Unity's dynamic fonts, anyway!), so the .fnt format would be the easiest way for most people to use your utility with Unity with minimal friction(since UIToolkit and NGUI are the most common UI solutions right now).

Lord Chumley
May 14, 2007

Embrace your destiny.

Lord Chumley posted:

Are there any guides on how to set up SDL 2.0 properly in Code Blocks? Google is not helping me at all and turning up older versions.

I found this website and I got Codeblocks set up. Just gonna put it here in case anyone needs it.

Problem Sleuth
Apr 12, 2011

WELCOME TO THE NEW FUTURE
Hey, thanks for answering my somewhat naive question about multiplayer programming! Between the answers and the stuff I've looked up on general network programming, it seems I severely underestimated the difficulty of it. Oh well, gotta start eventually. Anyway, I guess my question now is how do I go about starting? What languages/libraries work well with networking as far as game development goes?

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Problem Sleuth posted:

Hey, thanks for answering my somewhat naive question about multiplayer programming! Between the answers and the stuff I've looked up on general network programming, it seems I severely underestimated the difficulty of it. Oh well, gotta start eventually. Anyway, I guess my question now is how do I go about starting? What languages/libraries work well with networking as far as game development goes?
Most games roll their own because fast-paced games don't abstract it very far from the game logic and slower-paced games just use TCP which is easy. If you're using an existing engine then they probably have their own paradigm for networking things.

What kind of game are you making?

KoRMaK
Jul 31, 2012



https://code.google.com/p/lidgren-network-gen3/

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice

I was going to post this. Just grab some XNA and this library and go to town. An alternative would be using Unity since it's networking is 100x easier than handling packets by hand.

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost

OneEightHundred posted:

The simplest pattern for avoiding the whole mess is to treat structs as immutable values, similar to how strings already are.

Microsoft itself started pushing this as a best practice in, I dunno, .NET 3.0 or so. Basically if you're designing a struct they *strongly* recommend you make it immutable due to confusing use-cases like this.

ZombieApostate
Mar 13, 2011
Sorry, I didn't read your post.

I'm too busy replying to what I wish you said

:allears:
After dicking around with UIToolkit, I think I'm going to finish the system under the UI that I'm currently working on and then switch to the free version of NGUI in the hopes that I can buy it before I'm done with the game. Or hope that the new Unity GUI is semi-compatible and comes out before I'm done. It's not terrible, it just doesn't seem up to the task for anything more than a few loose buttons.

Edit: Apparently NGUI (at least whatever version the free edition is from) REALLY hates it if you try to make a GameObject, attach a UIAnchor script to it yourself and dump it in the hierarchy?
Edit2: Oh, I guess it's mostly Unity dumping random values in for the scale and position... why can't they just make everything start at the origin with no scale like civilized people? :saddowns:

ZombieApostate fucked around with this message at 23:02 on Sep 5, 2013

Problem Sleuth
Apr 12, 2011

WELCOME TO THE NEW FUTURE

OneEightHundred posted:

Most games roll their own because fast-paced games don't abstract it very far from the game logic and slower-paced games just use TCP which is easy. If you're using an existing engine then they probably have their own paradigm for networking things.

What kind of game are you making?

I'm planning on making something relatively slow-paced, so I'll probably just go ahead and use TCP if I decide to do it myself.


At first glance, this looks pretty cool, thanks!

And yeah, I'm definitely keeping "just use Unity" in the back of my mind in case I run out of steam for this whole thing.

ZombieApostate
Mar 13, 2011
Sorry, I didn't read your post.

I'm too busy replying to what I wish you said

:allears:
Ok, dumb NGUI question... I wrote essentially a listbox script (makes a list of buttons in a UITable) that I fill from code, which seems to work fine, but if I try to do:
code:
UICamera.selectedObject = entries[index];
to select the first entry in the listbox so something is actually selected when I hit play, that specific button appears in the middle of the screen instead of where it should be. I can find the UITable in the editor and click reposition, which puts it back where it should be, but when I hover over it, it tweens to the center of the screen again. The TweenPosition positions look like they're way off from where they should be, but if I change them, they get overwritten again on hover. I haven't done anything with any hover events or anything yet, so I don't know what the hell.

Edit: Screenshot if it makes it easier to picture. Attack is supposed to be on top of the list on the left:


Edit2: Also, is there any way to disable a widget, but still have it visible? Everything I've tried so far just hides it.
Edit3: I guess UIButton has an isEnabled property that I can use. Kind of annoying that GameObject uses the same term to hide stuff.

ZombieApostate fucked around with this message at 22:23 on Sep 7, 2013

Cirian
Nov 7, 2002
Fun Shoe
This is a bit of a crosspost from the Python thread, but anyone who's interested in 2D game dev using Python may be interested in the Bacon, which is made by the guy who made Pyglet some time ago. For the last few years, he's been working in the games industry with me making iOS titles, but he got some time to develop a successor to Pyglet for his Pyweek project, Monthly Visitor.

Bacon supports Windows and OSX, and has reasonable support for 2D shaders as well as built in image loading, input and sound functionality. I'm not much of a Pythoneer so I don't have much useful to say about it, but he's a drat good programmer so I trust what he makes :) I'll pass on any comments or suggestions to him directly!

Also for those of you on Windows, if you are using Visual Studio and you're not using Pytools, you really ought to be!

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
I'm implementing some simple persistence for my game engine. Anyone have any resources on this? My first instinct is to start simple with a serialized dictionary allowing me to get/set arbitrary values and refactor if necessary, but I would like to read about pitfalls with that approach.

Bongo Bill
Jan 17, 2012

Approach it from the perspective of finding a good way to load the game data, rather than save it.

Also, decide whether you want to serialize the entire game state, or just enough to be able to recreate the relevant parts. This decision involves engineering tradeoffs (such as preserving compatibility between versions) and game design concerns.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
I definitely don't care about serializing the entire gamestate. This is a zelda-like, I'm mostly interested in persisting major events, such as holes being blown up, blocks being moved, bosses being defeated, inventory, etc. This greatly simplifies the model.

I will think about versioning, that's definitely something to consider.

AntiPseudonym
Apr 1, 2007
I EAT BABIES

:dukedog:
The way I'm handling it at the moment is just having a big ole' hash map of strings to integers.

Some objects have components on them to set values in the map during certain events, such as a destructible wall setting NORTH_WALL_DESTROYED to 1. Then, when loading the level, check whether NORTH_WALL_DESTROYED is 1, and if it is, don't spawn it. Trying to get a value that doesn't exist in the map defaults to returning 0.

Then you can just save out all the key->value pairs and you're done.

You could also use booleans for this, but I find ints are a little more useful if you want to save stuff like health, ammo, number of times something has been triggered, etc. I've also written a little expression system so I can make it so that I can do stuff like NUM_OBJECTS_DESTROYED += 1 or check if NUM_OBJECTS_DESTROYED == 5, which helps out a bit for getting and setting values from data but it isn't strictly necessary.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
That is more or less what I'm doing (Dictionary in C# being the equivalent of a hash map). Except I'm not limiting myself to integers--I'm using anything that can be serialized. What are you going to do when you need to store, say, a player's name or a floating point number of some sort?

Unormal
Nov 16, 2004

Mod sass? This evening?! But the cakes aren't ready! THE CAKES!
Fun Shoe

Orzo posted:

That is more or less what I'm doing (Dictionary in C# being the equivalent of a hash map). Except I'm not limiting myself to integers--I'm using anything that can be serialized. What are you going to do when you need to store, say, a player's name or a floating point number of some sort?

You could use a simple little sqllite database. http://system.data.sqlite.org/index.html/doc/trunk/www/index.wiki

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

Orzo posted:

I will think about versioning, that's definitely something to consider.
What I've always done amounts to a versioned dictionary or cfg file, with an ordered list of "if ver < X, convert to Y" checks after the data's been loaded in but before I touch it anywhere. Where each check applies any fixes to data below X version, happening in version order so each check is working with the version it expects.

Obviously not a candidate for full gamestate persistence, but I've been quite happy with the results. That's what powered LEGO Unverse's massive CFG system, and it's worked fine in my smaller games as a per-save thing too.

EDIT: I kind of wish I'd been on early consoles, and gotten to try the memmap approach to persistence. That sounds awesome. But alas, bygone days. Besides, given storage sizes, I assume most did the dictionary/flag approach anyways, and the memmap was just for loading levels or setting state on boot.

Shalinor fucked around with this message at 15:29 on Sep 9, 2013

Unormal
Nov 16, 2004

Mod sass? This evening?! But the cakes aren't ready! THE CAKES!
Fun Shoe
I don't actually recommend this approach; but for Caves of Qud, I had a fully mutable world that I had to save off full chunks of to persist. The .NET serilizer died hysterically in a pile of flames when I tried to serialize a complex heiarchy with it. So I ended up writing cutom a reflection-based serializer somewhat based on this thing (http://www.codeproject.com/Articles/15700/Optimizing-Serialization-in-NET https://github.com/cosh/FastSerializer) that could just serialize my game-state in its entirety in chunks, with special code to save off global IDs for the main objects, and re-link the references at run-time when chunks are loaded.

In retrospect it was completely insane to even try to do this, but it works.

E: I ended up organizing the output on the file system, so a saved game was a big tree of files, and that sucked. So for my next secret insane project I'm jamming it all into a sqllite database. :woop:

Unormal fucked around with this message at 15:40 on Sep 9, 2013

Polio Vax Scene
Apr 5, 2009



I'm assigning each object a guid in my editor then certain classes have a 'persist' component. Whenever the player leaves a room, the room handler creates a serialized list of all persist objects and their attributes and guids. When the player enters a room, after the room handler is finished loading up the room, if the room handler finds a persist list, it goes through the list and updates each object based on the guid.

seiken
Feb 7, 2005

hah ha ha
I always liked protobufs as a general data serialization format and I'm using them or plan to use them for everything in my game (as a level format, for saved game state, and so on). You write a simple schema which auto-generates header files for your language of choice allowing you to load/save data which matches the schema. It can either save as a human-readable ASCII format or a super byte-efficient binary format.

For doing save-games with it I'd probably use a scheme where you just have a huge list of key-value pairs; if you need more than one value type you can shove in a bunch and make them optional. It's really designed for sending data across the wire but I always thought it a really good totally cross-language/platform compatible serialisation thing and I really like its design.

Unormal
Nov 16, 2004

Mod sass? This evening?! But the cakes aren't ready! THE CAKES!
Fun Shoe

seiken posted:

I always liked protobufs as a general data serialization format and I'm using them or plan to use them for everything in my game (as a level format, for saved game state, and so on). You write a simple schema which auto-generates header files for your language of choice allowing you to load/save data which matches the schema. It can either save as a human-readable ASCII format or a super byte-efficient binary format.

For doing save-games with it I'd probably use a scheme where you just have a huge list of key-value pairs; if you need more than one value type you can shove in a bunch and make them optional. It's really designed for sending data across the wire but I always thought it a really good totally cross-language/platform compatible serialisation thing and I really like its design.

I will second protobufs being a really nice thing in general. They have some really nice properties around older and newer systems being able to read older and newer versions of protobuf streams, since they were designed originally to be the backend data transport layer through backend systems at google that they didn't want to have upgrade all at once in order to add new functionality to the stream, so they were specifically designed to ensure forward and backwards binary comparability across versions. This is just one very nice property, and they are worth a look.

I've used this C# implementation in projects and it (mostly) works: https://code.google.com/p/protobuf-csharp-port/

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

Unormal posted:

So for my next secret insane project I'm jamming it all into a sqllite database. :woop:

SQLite friggin owns.

At work we're using SQLite as the basis for our archive format for all content and it is so drat useful. And fast. Being able to say "Give me a list of all content that has this set of metadata" is a heck of a lot easier than having to open up multiple files and parse the data for each, then store that somewhere in memory.

In some cases we're also getting better load times than if we were to read the file straight into memory.

xzzy
Mar 5, 2009

My only reservation with sqlite is the syntax isn't exactly the same as mysql, which totally breaks my brain. To be fair, I have this issue with Oracle's db too.

xgalaxy
Jan 27, 2004
i write code
I have a stupid question about NGUI.

How does the event system work exactly? Is it like Flash where it will 'bubble' events up to the parent container? I guess what I'm looking for is a way to handle buttons events without attaching a MonoBehavior to every clickable/touchable UI component. Is this possible? Looking at the documentation this doesn't appear possible but maybe I'm missing something obvious.

I guess by virtue of being a button its got a mono component attached to the 'display' object anyway. So I guess I could derive from the base button and implement my own 'bubble'ing code. Maybe that is the way to go?

xgalaxy fucked around with this message at 18:45 on Sep 9, 2013

Thermopyle
Jul 1, 2003

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

xzzy posted:

My only reservation with sqlite is the syntax isn't exactly the same as mysql, which totally breaks my brain. To be fair, I have this issue with Oracle's db too.

Maybe this is too heavy for a game, but what about using a lightweight ORM and abstract away the differences?

xzzy
Mar 5, 2009

Would probably work in the technical sense, but I'm not a huge fan of adding abstraction to cover my own inadequacies. :v:

Plus, the SQL statements still have to exist somewhere, and my "problem" is remembering the syntax differences without using google.

ZombieApostate
Mar 13, 2011
Sorry, I didn't read your post.

I'm too busy replying to what I wish you said

:allears:

xgalaxy posted:

I have a stupid question about NGUI.

How does the event system work exactly? Is it like Flash where it will 'bubble' events up to the parent container? I guess what I'm looking for is a way to handle buttons events without attaching a MonoBehavior to every clickable/touchable UI component. Is this possible? Looking at the documentation this doesn't appear possible but maybe I'm missing something obvious.

I guess by virtue of being a button its got a mono component attached to the 'display' object anyway. So I guess I could derive from the base button and implement my own 'bubble'ing code. Maybe that is the way to go?

I'm having the same issue. I wrote a listbox using NGUI's buttons and a UITable, but I'd rather the listbox gameobject that contains everything handle broadcasting events. I couldn't find any decent built in way to pass events up to parents. You could probably use SendMessage or Broadcast or whatever, but those are apparently really slow and I'm not a huge fan of putting the function name in as a string.

My solution was to use UIEventListener in the listbox to listen to the button events, and then use C# events and delegates to rebroadcast it. That would probably be a pain if you really wanted to bubble the event all the way up to the root, but it worked for my purposes. Gotta agree that it's pretty awkward if you've ever written code for a GUI before. It took me a while to get used to using anchors instead of having an actual window, too.

xgalaxy
Jan 27, 2004
i write code

ZombieApostate posted:

I'm having the same issue. I wrote a listbox using NGUI's buttons and a UITable, but I'd rather the listbox gameobject that contains everything handle broadcasting events. I couldn't find any decent built in way to pass events up to parents. You could probably use SendMessage or Broadcast or whatever, but those are apparently really slow and I'm not a huge fan of putting the function name in as a string.

My solution was to use UIEventListener in the listbox to listen to the button events, and then use C# events and delegates to rebroadcast it. That would probably be a pain if you really wanted to bubble the event all the way up to the root, but it worked for my purposes. Gotta agree that it's pretty awkward if you've ever written code for a GUI before. It took me a while to get used to using anchors instead of having an actual window, too.

I've noticed that some of the built in NGUI MonoBehaviors have an eventReceiver that you can assign that will pass the event onto the specified game object, while others do not. Seems strange that this isn't available for them all.

stramit
Dec 9, 2004
Ask me about making games instead of gains.
NGUI does not have event bubbling as far as I am aware. New Unity GUI does.

ZombieApostate
Mar 13, 2011
Sorry, I didn't read your post.

I'm too busy replying to what I wish you said

:allears:
Huh, I haven't seen that. UIEventListener kind of does the same thing from the other direction I guess? If I want to listen to a button's OnClick, I do something like this:

code:
public class A
{
	UIButton b = GameObject.Find("B").GetComponent<B>().button
	UIEventListener.Get(b).onClick += myOnClick;

	public void myOnClick(GameObject go)
	{
		//do stuff here
	}
}

//there's a button in here
public class B
{
	public GameObject button;
	void Start()
	{
		button = GameObject.Find("ButtonNameHere");
	}
}
And it will catch the button event fired from B's button in A. The eventReceivers are probably using the same thing, but why don't they have that built in to everything? :iiam:

xgalaxy
Jan 27, 2004
i write code

ZombieApostate posted:

Huh, I haven't seen that. UIEventListener kind of does the same thing from the other direction I guess? If I want to listen to a button's OnClick, I do something like this:

.. code ..

And it will catch the button event fired from B's button in A. The eventReceivers are probably using the same thing, but why don't they have that built in to everything? :iiam:

Yea. UIEventListener does what I need well enough. Here is what I did:
code:
using UnityEngine;
using System.Collections;

public class MainMenuScript : MonoBehaviour {
	
	public GameObject topButton;
	public GameObject middleButton;
	public GameObject bottomButton;
	
	// Use this for initialization
	void Start () {
		UIEventListener.Get(topButton).onClick += OnTopButtonClicked;
		UIEventListener.Get(middleButton).onClick += OnMiddleButtonClicked;
		UIEventListener.Get(bottomButton).onClick += OnBottomButtonClicked;
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	void OnTopButtonClicked(GameObject obj) {
		Debug.Log("Top button was clicked.");
	}
	
	void OnMiddleButtonClicked(GameObject obj) {
		Debug.Log ("Middle button was clicked.");
	}
	
	void OnBottomButtonClicked(GameObject obj) {
		Debug.Log("Bottom button was clicked.");
	}
}
And then in the editor I just assign the appropriate game objects to the topButton, middleButton, and bottomButton properties.


How do you handle the different UI screens for your game? Do you have each major UI section in its own scene and then just add them and remove them from the main game scene as needed?

xgalaxy fucked around with this message at 19:51 on Sep 9, 2013

Adbot
ADBOT LOVES YOU

ZombieApostate
Mar 13, 2011
Sorry, I didn't read your post.

I'm too busy replying to what I wish you said

:allears:
Ahhh, being able to set things from the editor, what a luxury :allears:. I have to populate everything from code, so I don't get to do that :saddowns:.

Edit: moved this bit to a new post in case it got missed

ZombieApostate fucked around with this message at 20:01 on Sep 9, 2013

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