Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 552 553 [554] 555 556 ... 796

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

Dutrius

  • Bay Watcher
  • No longer extremely unavailable!
    • View Profile
    • Arcanus Technica
Re: if self.isCoder(): post() #Programming Thread
« Reply #8295 on: October 26, 2015, 02:11:44 pm »

I haven't actually started yet, thankfully. I am, however currently wrapping my head around the sort of interface it would use. Or at least trying to.


I don't even have an iPad.
Logged
No longer extremely unavailable!
Sig text
ArcTech: Incursus. On hold indefinitely.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8296 on: October 26, 2015, 02:15:23 pm »

You could build a roguelike in Unity, push it to both iOS and Android. It might not be as lightweight as a native app, but you have the cross-platform thing fully covered. You also have the advantage that you can prototype your whole thing on PC then, and worry about platforms (or porting) later once you at least have a playable concept. Unity 5 is completely free to dev and release games, I think you only need to buy a license if you make $100,000 per year off your games.
« Last Edit: October 26, 2015, 02:17:34 pm by Reelya »
Logged

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #8297 on: October 26, 2015, 02:23:16 pm »

You can actually coerce both C++ and .NET (so C#) into running on Android and iOS. I suspect most big cross-platform 2D games are based in MonoGame via Xamarin (Towerfall, for example).

SDL2 and SFML both have iOS and Android support (experimental for SFML though), and you can go all out and use raw OpenGL on all of those if you know what you're doing.

There is also HTML5, so (Java/Type/Coffee)script and Canvas, which will run on Android and iOS and can be wrapped up and turned into applications. Heck, if you wanted to be utterly insane you could compile SDL2 + C++ into HTML5 via Emscripten.

Basically the options are there, so if you pick a tool and google a bit you may be able to find out how to mobileify it with some elbow grease :)
« Last Edit: October 26, 2015, 02:48:02 pm by MorleyDev »
Logged

Hugehead

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8298 on: October 26, 2015, 04:00:42 pm »

Android apps are written in a specific variety of Java. I don't know about iOS apps, but you'd have to pay to get one onto the app store anyway.
Yes,  but the actual drvice, under that, runs a flavor of Linux, right?

E-eh. I don't know if I'd go that far (UNIX might be more accurate), because whilst I think it may be true in the strictest sense it's probably about as closely related to common distros of Linux as MacOS or whatever Macs run is.

It's possible to play DF on a tablet if you SSH into a PC, though.
It's worth a shot though.
Android does run a modified version of the Linux kernel, but this doesn't make it very similar to the GNU/Linux systems you may be familiar with. Above the kernel Google have their own libraries and API, which lack some features necessary in GNU/Linux systems. Further, on top of the libraries Android has a custom built Java virtual machine where userspace applications you run live. There are some tools to build native code for Android that you can call from the JVM, but due to the nonstandard libraries I don't believe it's as simple as just compiling your existing code using the tools. Note that I am no expert in Android development, especially regarding native code, but I think this is fairly accurate.
Logged
We're Bay12er's. If there is a bug, we will find it, exploit it, and make a recursive statue out of it. Just look up Planepacked.
When a dwarf enters a martial trance, they become Jedi. Short, drunken Jedi.

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8299 on: October 26, 2015, 04:20:49 pm »

there is, however, nothing stopping you from installing, like, debian on your android phone or whatever. because apple a shit you should give up all hope of running it on a phone or tablet made by apple, though.
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

Dutrius

  • Bay Watcher
  • No longer extremely unavailable!
    • View Profile
    • Arcanus Technica
Re: if self.isCoder(): post() #Programming Thread
« Reply #8300 on: October 26, 2015, 06:59:30 pm »

Logged
No longer extremely unavailable!
Sig text
ArcTech: Incursus. On hold indefinitely.

Gatleos

  • Bay Watcher
  • Mournhold... City of Light... City of MAGIC!
    • View Profile
    • Someone Sig This
Re: if self.isCoder(): post() #Programming Thread
« Reply #8301 on: October 26, 2015, 08:23:13 pm »

So today I went back to a programming problem I haven't considered for a long time: collision handling. Disregarding the math involved in just detecting a collision between two objects, what's the usual OOP method of handling the behavior of many different combinations of object types that could be colliding? I'm working in c++, so my first instinct was of course to use inheritance of some kind. This leads to an abstract class something like this:

Code: [Select]
class Collider {
public:
Rectangle bounds;
virtual void onCollide() = 0;
};

Then I can have data structures like Quadtrees that help me efficiently determine which objects to collide, and populate it with pointers to Collider-derived objects. The problem, of course, is that the main requirement of collision handling is that I know what type both objects are. My handy virtual function lets me define behavior based on what this object is, but what about the other one? The best I can accomplish with this model is
Code: [Select]
virtual void onCollide(Collider& c) = 0;...Which doesn't tell me much at all.

The inheritance system in c++ doesn't seem to be equipped for this kind of thing; it seems that any solution which takes many types into account starts to defeat the purpose of using inheritance at all. Everything I try seems to end up as a mess of redundant definitions, and the combinatorial explosion will kill me later on if I'm not careful.
Logged
Think of it like Sim City, except with rival mayors that seek to destroy your citizens by arming legions of homeless people and sending them to attack you.
Quote from: Moonshadow101
it would be funny to see babies spontaneously combust
Gat HQ (Sigtext)
++U+U++ // ,.,.@UUUUUUUU

Bauglir

  • Bay Watcher
  • Let us make Good
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8302 on: October 26, 2015, 09:52:37 pm »

I'll be honest, I have no idea what the standard approach would be, but if it were me I'd construct some larger container that contains information about every object that can collide, does collision detection, and calls each object's internal collision response function when one happens. To the extent that each object needs to know things about the other, it may also call various getters prior to calling the collision response functions.

of course i think there's a lot of equivocation around the word "object" in what i just wrote but hopefully it is effective?
Logged
In the days when Sussman was a novice, Minsky once came to him as he sat hacking at the PDP-6.
“What are you doing?”, asked Minsky. “I am training a randomly wired neural net to play Tic-Tac-Toe” Sussman replied. “Why is the net wired randomly?”, asked Minsky. “I do not want it to have any preconceptions of how to play”, Sussman said.
Minsky then shut his eyes. “Why do you close your eyes?”, Sussman asked his teacher.
“So that the room will be empty.”
At that moment, Sussman was enlightened.

monkey

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8303 on: October 26, 2015, 10:01:31 pm »

Double/Multi dispatch or the visitor pattern.

Code: [Select]
class Triangle;
class Circle;

class Shape {
public:
  virtual void onCollide(Shape* other) = 0;
  virtual void collide(Triangle*) = 0;
  virtual void collide(Circle*) = 0;
};

class Triangle : public Shape {
public:
  virtual void onCollide(Shape* other) { other->collide(this); }
  virtual void collide(Triangle*) { std::cout << "triangle-triangle" << std::endl; }
  virtual void collide(Circle*) { std::cout << "circle-triangle" << std::endl; }
};

class Circle : public Shape {
public:
  virtual void onCollide(Shape* other) { other->collide(this); }
  virtual void collide(Triangle*) { std::cout << "triangle-circle" << std::endl; }
  virtual void collide(Circle*) { std::cout << "circle-circle" << std::endl; }
};

int main()
{
  Shape* c = new Circle();
  Shape* t = new Triangle();

  t->onCollide(c);
  t->onCollide(t);
  c->onCollide(c);
  c->onCollide(t);
  return 0;
}
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8304 on: October 26, 2015, 10:55:42 pm »

What are you doing?

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8305 on: October 26, 2015, 11:39:11 pm »

Learning  how to program using graphics.

Hahahahahaha no.

I've done quite a bit of programming, but raw opengl is still techno-voodoo for me.
Logged

EnigmaticHat

  • Bay Watcher
  • I vibrate, I die, I vibrate again
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8306 on: October 27, 2015, 12:07:32 am »

Learning  how to program using graphics.
Use SDL and keep it 2D :P
Logged
"T-take this non-euclidean geometry, h-humanity-baka. I m-made it, but not because I l-li-l-like you or anything! I just felt s-sorry for you, b-baka."
You misspelled seance.  Are possessing Draignean?  Are you actually a ghost in the shell? You have to tell us if you are, that's the rule

Moghjubar

  • Bay Watcher
  • Science gets you to space.
    • View Profile
    • Demon Legend
Re: if self.isCoder(): post() #Programming Thread
« Reply #8307 on: October 27, 2015, 12:13:11 am »

Learning  how to program using graphics.

Hahahahahaha no.

I've done quite a bit of programming, but raw opengl is still techno-voodoo for me.

If you really want to learn OpenGL, theres some pretty good tutorials out there.  NeHe is pretty amazing: http://nehe.gamedev.net/

You'll eventually need to look at the specs (pdf files), and look at the redbook http://www.glprogramming.com/red/
I had another good source but it page-sploded.  In any case, I honestly didn't think it was that rough, once you got started (though I'm nowhere near an amazing expert on it now, for sure; I just generally know how to do things like draw stuff, 3d math, shaders, VBO, etc).
Logged
Steam ID
Making things in Unity
Current Project: Demon Legend
Also working on THIS! Farworld Pioneers
Mastodon

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8308 on: October 27, 2015, 12:14:29 am »

OpenGL it is then.
Things to know:
Shaders are programs run by the GPU.

There are two main flavors of shaders when starting out:
    Vertex Shaders which deal with mathematically putting your points (vertices) into place.
    Pixel Shaders which deal with coloring the pixels of your triangles.

You feed the GPU a bunch of vertex data containing info about your vertices (aka points; but always called vertices), as well as a bunch of other data in textures or buffers.

The GPU transforms this data using the set Vertex Shader (you will generally define this) into the points used for rendering to the screen. Usually involves transformation matrix or two which turn your 3D coordinates into 2D screen coordinates.

The GPU then uses these points either on their own or with a buffer of indices into the vertex data to figure out which vertices go together to form your triangles. It fills in all of the pixels within said triangles, so long as they are going to be on screen.

The GPU then goes through each pixel and runs the Pixel Shader (you will generally define this) on each of them. The inputs for this come from the outputs of your earlier Vertex Shader and any other textures/buffers you sent it. Inputs for a pixel from a vertex shader output will be linearly interpolated across the surface of the triangle, based on how far it is from the 3 vertices making up the triangle.

The final pixel colors go into a screen buffer, and when you're done, you swap (aka Present) that buffer with the one being displayed.

These are the core ideas to start out with. All the rest is (necessary) bureaucracy managing the fact that the GPU is essentially a second computer you're controlling over a specialized 50GB/s, 4 inch long network. This results in making sending data and programs (shaders) to the GPU and getting everything set up seem a bit long-winded the first time.

GLHF.
« Last Edit: October 27, 2015, 12:16:17 am by alway »
Logged

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #8309 on: October 27, 2015, 03:49:18 am »

Let's be honest, there's basically no reason why someone would want to write their own rendering code instead of using an existing wrapper or engine, other than learning or a masochistic desire for utmost efficiency.
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.
Pages: 1 ... 552 553 [554] 555 556 ... 796