Jump to content

  • Log In with Google      Sign In   
  • Create Account

Nypyren

Member Since 19 Aug 2002
Offline Last Active Today, 09:50 AM

#5297767 Is there any reason to prefer procedural programming over OOP

Posted by Nypyren on 23 June 2016 - 07:23 PM

You cannot do procedural programming in Java

 
You can't do it in C# either yet you use it as an example.


As far as I was aware, the only requirement to be 'procedural' were procedures (functions, methods, etc). I'm not sure what kind of silly semantic games you guys are playing here...

Are you saying that because you have to define functions inside organizational units called classes, it's no longer a procedure?

To me, procedural/object oriented is a *mentality*:
 
// procedural mentality
foreach (thing in collection)
{
    DoOperation(thing, additionalParameters);
}
// object oriented mentality
var visitor = new DoOperationVisitor(additionalParameters);
visitor.Traverse(collection);
// functional mentality
collection.ForEach(x => DoOperation(x, additionalParameters)); // But seriously, don't use ForEach
I don't see much dogma in .Net. Dogma in programming means "lack of flexibility". .Net is anything but inflexible...
 
File.WriteAllBytes, File.WriteAllText // Procedural convenience functions

Stream, FileStream, StreamWriters, BinaryWriters // Object oriented composition

collection.Select(x => x.Name).OrderBy(x => x).ToList(); // Functional pipelining

UIElement // Type hierarchies in WPF with decent polymorphism and data binding; Object oriented and declarative

IAsyncResult // Capable of being used via polling, callbacks, WaitHandles, mixed with async/await, etc.
C# doesn't force you to solve your problem in one way. I think that's what Ravyne meant.


#5297544 Is there efficient FREE way yo encode / encrypt the resource files ? ( like u...

Posted by Nypyren on 22 June 2016 - 01:38 AM

You can encrypt files as much as you want, but the game will need to decrypt them, and since the users will have the game... the users will be able to decrypt them as well.


#5297476 Should video game mechanics be scripted?

Posted by Nypyren on 21 June 2016 - 11:56 AM

Yes, with big multi-platform mobile projects you usually don't have a choice. And I also agree that C++ is not a language suited for rapid iteration. With the project I mentioned above, there's both necessary evil (the platform-specific plugins) but also some unnecessary stupidity (the use of PHP instead of a superior-in-all-respects choice like Java or C#).

Binding/interop STARTS easy with trivial function calls using primitive types as arguments and return values. That's a cakewalk. But it can get really, really bad. The more complex the thing you need to do, the more likely you will need more complex data structures, which brings in marshalling. Some interop systems don't have a good marshalling mechanism, so people where I work fall back to JSON.

For responsiveness, we write a lot of asynchronous code. We'll have cases where language A invokes a function in language B, which starts a threaded operation. When it's done, it needs to post its result back to language A. Cross-language support to deal with asynchronous operations is pretty weak in my experience (outside of .Net, anyway).

Unity in particular has provided a terrible way to callback from plugins to Unity: UnitySendMessage(string gameObjectName, string functionName, string parameter). Invoking it requires Unity to search the scene for that GameObject, search for the function over all components on that object using reflection, and the function needs to parse the argument(s) from the string. Not only is this horrible from the performance standpoint, but in the C# IDEs there's nothing in the code that indicates that the function is actually being called anywhere. If you rename the function or game object, the only indication you get that something is broken is QA saying "feature XYZ doesn't work" and a failure message buried in the device's log spam.

Callbacks aren't REQUIRED; you can instead have language A poll language B to see if a task has completed. But then you need to store the result somewhere and have a task ID that the Begin call returns to language A, so that language A can ask language B "what's the status of operation #ID?". If you intend to ever let two or more tasks execute simultaneously, it starts getting to be a pain to implement the bookkeeping for this.

In some cases you can have language A start up the worker thread and use a simple blocking call to language B, but in cases like Android or WSA where you need to do a "Run On UI thread" operation, language A doesn't HAVE the ability to queue up work on that thread.

So yeah - complexity.


#5297417 Should video game mechanics be scripted?

Posted by Nypyren on 21 June 2016 - 01:27 AM

I'm with Hodgman; scripting languages are just another way of telling a computer to do something. But I also want to describe the decision making process you should use when thinking about using multiple languages in a project, regardless of whether they're scripting languages or "major" languages:

I'm of the opinion that a project should minimize its complexity. In programming, Complexity == Burden. And multiple languages can be a big complexity.

Burdens may include (but are not limited to): Programmer inexperience with the scripting language and its APIs, interop overhead between the language and the host code, weaker performance, worse debugging, inferior IDEs, and poorly-maintained documentation.

There needs to be some major benefit you get from using multiple languages that offsets the burden. Perhaps you can change scripts and have them take effect while the game is still running, making iterating on new ideas much faster. Perhaps you can use scripts to hotfix something in an iOS game that you'd normally have to put in a new release and wait two weeks for Apple to approve. Things like that. And on rare occasions, you use another language because you must.

I've been on projects where we have:

- Unity engine (C++, Java, Objective-C and C#).
- C# 3.0 w/ .Net 3.5-equivalent BCL for the game code.
- Java code for Android plugins, using an inconsistent mess of build scripts for ant and gradle, with projects in Eclipse, NetBeans, or IntelliJ.
- Objective-C and C++ code for iOS plugins.
- C# 5.0 and different BCLs for WP8 and WSA plugins and host project (which is incompatible with the C# 3.0 game code in small but extremely annoying ways; thanks Microsoft and Unity!).
- PHP, Java, AND Python for the web services the game talks to.
- Perl, PHP, Python, Bash, Java and C# command line utilities (someone fucking wrote a command line tool in PHP, I shit you not).

It's just a fucking nightmare. It's job security, but almost to the point where you can no longer ship the game due to the burden.

I highly recommend thinking VERY carefully about whether you NEED that additional burden, or if it would be simpler to just stick with one consistent codebase.


#5297239 Is there any reason to prefer procedural programming over OOP

Posted by Nypyren on 19 June 2016 - 12:42 PM

ALL programming consists of functions that operate on data, though.

I've been programming for so long that the distinctions between programming styles no longer mean anything to me. They're just different representations of the same underlying processes. It's just a matter of how conveniently the language lets you represent what you want to do. The specific thing that the program needs to do is what I'm interested in - it lets me decide how I want to implement it. This is why I didn't like your example; it doesn't do anything, and there's no context for why you might want to encapsulate that integer or not, so there's no need to pick a particular solution.

You should use whatever style you prefer, based on your knowledge of the problem you want to solve and the possible options the language and APIs allow you to pick from.


#5297052 Oculus DK2 ghosting/low-persistence issue

Posted by Nypyren on 17 June 2016 - 06:45 PM

Sounds like something that happened to one of my Logitech mice; its onboard firmware got corrupted so that its "onboard" profile wouldn't send clicks. I had to plug in another mouse to access the configuration software. The physical buttons were fine, and once the config software told the mouse to run in "game detection" mode, it could click fine.

I ended up giving up and getting a new mouse, but obviously DK2s are a bit more expensive than that.


I would try re-flashing its firmware and see if there's some way to factory reset it.

If not then it's likely your device is permanently damaged...


#5295135 Help With Serialization

Posted by Nypyren on 05 June 2016 - 02:41 PM

Here's what I would change:
 
public PlayerProfile LoadPlayerProfile()
->
public static PlayerProfile LoadPlayerProfile()
Game1.PlayerProfile = Game1.PlayerProfile.LoadPlayerProfile();
->
Game1.PlayerProfile = PlayerProfile.LoadPlayerProfile();
This will allow you to load the profile without instantiating a "placeholder" instance that gets overwritten immediately.

My personal habit is that any time I see a function that doesn't use any member variables of the class it's in, and isn't virtual, I make it static.


#5295040 Help With Serialization

Posted by Nypyren on 04 June 2016 - 10:53 PM

That's C#, and the BinaryFormatter is capable of serializing cyclic digraphs (i.e. anything). Those functions should work as written. Can you post those your other code as well?

They will work, however your deserialization method should be static. How are you calling it? Are you making a PlayerProfile instance, deserializing the data, and then throwing away the return value? That would be your problem, if so.

The BinaryFormatter.Deserialize will create new objects; it won't fill in the fields of your existing object.


#5294751 How difficult is this instance of this puzzle?

Posted by Nypyren on 02 June 2016 - 11:22 PM

I got the small words almost immediately by hand (frequency analysis; got every letter used 3 or more times on the first guess), but had to use an online solver to get the large ones. The online solver got the whole thing instantly. I can't brute force dictionary words in my head like it can.


#5294268 Virtual functions are not called from a static library

Posted by Nypyren on 31 May 2016 - 12:04 AM

Sometimes, if the debugger is confused enough, it won't be able to find the memory address that it needs to place a breakpoint on. Sometimes it'll tell you this, sometimes you can miss it.

If a breakpoint suspiciously fails, try logging something - your code might indeed be executing.


#5293502 Do you usually prefix your classes with the letter 'C' or something e...

Posted by Nypyren on 25 May 2016 - 11:51 PM

My keyboard doesn't have a '' key. So I an't prefix my lasses. :(

It's pretty hard to ode in /++ or #.


#5293066 how much PC do you need to build a given game?

Posted by Nypyren on 23 May 2016 - 09:41 AM

(For some reason quoting your last post pulls in a ton of font formatting info, so I'm avoiding that.)

RE: Windows background processing:

Right now, monitoring process use on Windows 10: I have about 70 processes running, and about two dozen of them are using "0.01%" of my CPU at any given time. The rest are using 0%. It's insignificant, at least for me.

The only time I ever notice a "background process" sucking down CPU time is at work where our mandated Kaspersky antivirus software does its periodic scans that bring my work laptop to its knees. But that was true in Windows 7 through Windows 10, and isn't the OS's fault.

Back when CPUs were just getting two cores, I noticed a big improvement when I got my first 2-core PC, but I haven't noticed any difference in background task handling since then.


#5292911 Issue with convertion C++ code to C# for TGA loading

Posted by Nypyren on 22 May 2016 - 01:21 PM

If you tested the C++ code with the image you're using, and it works, then the image isn't relying on cross-scan packets (programs that save the TGA files sometimes intentionally split runs when the end of a scanline is reached). In that case there's probably a bug in your transliteration of the C++ code.

The main gotcha that I have run into when transliterating C++ -> C# is the differences in implicit casting between different sizes of integers that C# uses.

What I would do next is run the C++ and C# code in debuggers and step through them in parallel with the same TGA file until you see where values diverge.


#5292690 how much PC do you need to build a given game?

Posted by Nypyren on 20 May 2016 - 02:35 PM

Cache is part of the CPU and cannot be purchased separately.

If you want to build a PC from parts, this is the process I use:

- Find desired CPU in my price range.
- Find desired GPU in my price range.
- Find a motherboard that is compatible with both (Supported CPU socket type/generation, PCI Express version).
- Find a case which is large enough for everything (Large video cards can sometimes be too large to fit in certain cases).
- Find RAM that is compatible with the motherboard (there are RAM compatibility lists provided by motherboard makers). Buy them in bundles, not separately. Bundles are tested together.
- Find a good quality PSU with enough watts to feed your CPU and GPU.
- (Optional) Get an aftermarket CPU HSF (Heat Sink + Fan) if you want it to be quieter/cooler than the stock HSF. These are specific to the CPU socket type, and you also need to make sure the motherboard layout has room if the HSF is large.
- Find a SSD/HDD with zero customer complaints related to hardware incompatibility and minimal complaints about failures.

My current PC is:
CPU: AMD FX-6300 (midrange)
GPU: Nvidia GTX 980 (high end)
MB: Gigabyte GA-990FXA-UD3 (midrange)
RAM: 32GB (4x8GB) G-Skill Ripjaws X (midrange)
Case: Cooler Master CM690 II
PSU: Corsair 750-watt (This is way more than I need for my PC but I reuse it each time I upgrade so it's somewhat future-proof)
HSF: Zahlman CNPS 9500

Overall this is a "high end" PC for my use cases simply due to the GTX 980's outstanding performance and the fact that most games I play are GPU-bound. This PC would be overkill for game development.

Suggestions:
- Take all benchmarks with a grain of salt; I have had a perfect time with AMD processors even though they look terrible according to benchmarks.
- AMD CPUs and compatible motherboards are MUCH cheaper than Intel's.
- AMD's motherboard chipset drivers are much more reliable than Intel's. Intel tends to be really flaky when it comes to drivers.
- Nvidia is far better at supporting new games with updated drivers than AMD is. However, as a game developer you MUST test on both.
- For game development, buy midrange GPUs of both brands so you can tune your performance and cater to a larger audience.
- Try to get your game to use 4GB or less. The more RAM you use the more likely you will cause your players' unknown amount of RAM to start paging to disk, which kills performance.


#5292341 What is the top factor for MMO engines limiting world size?

Posted by Nypyren on 18 May 2016 - 02:47 PM

If the game world was huge you could travel for hours before encountering another player, and all the players would congregate in cities leaving the rest of the game world a boring empty ghost town.


You've just described Elite: Dangerous! :)




PARTNERS