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
Jo
Jan 24, 2005

:allears:
Soiled Meat

roomforthetuna posted:

Nothing wrong with that if it looks awesome.
(Unless there's some sort of legal/licensing problem.)

The image is from GIS. It's an overhead image of Pripyat, an abandoned Soviet city near Chernobyl. It's not free or creative commons. Copyright. :argh:

Adbot
ADBOT LOVES YOU

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Vinterstum posted:

Assuming you're making a C++ Android port (This may be a flawed assumption on my part; I know absolutely nothing about android development), I doubt a port would be much more than a few weeks worth of work on the programming side. If you're porting the whole thing to Java though, forget everything I just wrote.

Android stuff has to be done in Java, right? No C++?

TJChap2840
Sep 24, 2009

Bob Morales posted:

Android stuff has to be done in Java, right? No C++?

There are C++ engines that allow you to develop for Android.

Nalin
Sep 29, 2007

Hair Elf
Android can do native code; however, when using native code, you can't access features like Services and Content Providers, so you will have to write a Java wrapper. Also, only Android 2.3+ supports the ability to handle events such as onCreate(), onPause(), and onResume() via native code. If you want to support Android 2.2 and below, you will also need to write a Java wrapper.

Physical
Sep 26, 2007

by T. Finninho
I'm trying to sign up for an account at box2d forums and they have the hardest spam-bot protection ever. Here is one of the questions

A ball of mass 3 kilograms begins falling with gravity of 10 meters per second squared. How many meters does it fall in 8 seconds?:
This question is a means of preventing automated form submissions by spambots.

I still haven't been able to register and ask my question :(

Nalin
Sep 29, 2007

Hair Elf

Physical posted:

I'm trying to sign up for an account at box2d forums and they have the hardest spam-bot protection ever. Here is one of the questions

A ball of mass 3 kilograms begins falling with gravity of 10 meters per second squared. How many meters does it fall in 8 seconds?:
This question is a means of preventing automated form submissions by spambots.

I still haven't been able to register and ask my question :(
Ah ha. That's amusing. Here, let me help:

d = (1/2) * g * t^2
d = (1/2) * (10 m/s) * (8s)^2
d = (1/2) * (10 m/s) * 64s
d = (1/2) * 640m
d = 320m

Stiggs
Apr 25, 2008


Miles and miles of friends!
I'm trying to make a sprite move towards the position that I click on on the screen, which is simple enough, but I want to make sure that the sprite can only move forwards in the direction that it's facing (it also rotates to face where I clicked).

I can do both of these things seperately, like so:

code:
//Move to mouse
sprite.x = sprite.x - (sprite.x - sprite.destinationX) * sprite.speed
sprite.y = sprite.y - (sprite.y - sprite.destinationY) * sprite.speed
code:
//Move in the direction it's facing
sprite.x = sprite.x + sprite.speed * math.cos(sprite.rotation)
sprite.y = sprite.y + sprite.speed * math.sin(sprite.rotation)
But I can't figure out how to combine them both!

I am absolutely awful at maths so I might be missing something simple. Any ideas?

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
It sounds like you want to keep the 2nd part of your code--move in the direction it's facing--while replacing the first part with a change in rotation. Figure out the 'destination rotation angle', which can be calculated as a function of the current position and the target position (subtract the vectors and use an arctangent or something, if you don't know how to do this I could elaborate). So now you have two angles, the current angle and the destination angle, and you can interpolate between those two every frame. The result will be an arc-like trajectory to where you clicked the mouse.

Is this what you were looking for?

Stiggs
Apr 25, 2008


Miles and miles of friends!

Orzo posted:

It sounds like you want to keep the 2nd part of your code--move in the direction it's facing--while replacing the first part with a change in rotation. Figure out the 'destination rotation angle', which can be calculated as a function of the current position and the target position (subtract the vectors and use an arctangent or something, if you don't know how to do this I could elaborate). So now you have two angles, the current angle and the destination angle, and you can interpolate between those two every frame. The result will be an arc-like trajectory to where you clicked the mouse.

Is this what you were looking for?

This isn't exactly what I'm looking for, unless I'm misunderstanding which is fairly likely! I made an image to try and make myself clearer.



The top part is what's happening now. I'll click somewhere and the image will move in a straight line towards it while rotating. The bottom is what I want. If the image is facing left and I click somewhere to the right of it, I want it to have to do a U-turn because it can only travel forwards.

Fake edit: While drawing the image and writing this, I've been thinking and I'm pretty sure I can just perform the rotation like normal while applying acceleration in the forward facing direction until x = destinationX or something. I think I was overcomplicating it!

Stiggs fucked around with this message at 01:19 on Mar 19, 2012

h_double
Jul 27, 2001
A couple of Unity questions:


1) I'm using the First Person Controller for the player object (which is simulating a boat with an engine), and want to have separate acceleration and deceleration rates for forward movement. That is, going forward will ramp up to MaxGroundAcceleration fairly quickly, but when the forward input is released, the speed will taper off at a slower rate. I've looked at the CharacterMotor and FPSController scripts, which look like they ought to be the right place, but am not quite sure what to change.

2) I have the controls for turn left/right assigned to keys, by redefining the MouseX section of the Input Manager. I turned down the MouseX sensitivity so that holding down the left/right keys will increase the turn speed, but I would also like the turn speed to taper to zero when not turning. Additionally, I only want the player to be able to turn when moving forward (since it's a boat). Where/how can I define this behaviour?

Centripetal Horse
Nov 22, 2009

Fuck money, get GBS

This could have bought you a half a tank of gas, lmfao -
Love, gromdul

Stiggs posted:

Fake edit: While drawing the image and writing this, I've been thinking and I'm pretty sure I can just perform the rotation like normal while applying acceleration in the forward facing direction until x = destinationX or something. I think I was overcomplicating it!

This is correct, simply apply thrust while continuing to rotate until you are facing your destination. Just be sure that your acceleration doesn't force you into an eternal orbit around the destination point.

Edit: I actually have code for this in two languages (Monkey and AS3) if you need further help. In my code, the actor is continuously following the mouse, but it would be easy to modify it to aim at a single point.

Stiggs
Apr 25, 2008


Miles and miles of friends!

Centripetal Horse posted:

This is correct, simply apply thrust while continuing to rotate until you are facing your destination. Just be sure that your acceleration doesn't force you into an eternal orbit around the destination point.

Edit: I actually have code for this in two languages (Monkey and AS3) if you need further help. In my code, the actor is continuously following the mouse, but it would be easy to modify it to aim at a single point.

I'd love to take a look at your AS3 code if you don't mind, I'm still getting a little stuck over here. :)

SuicideSnowman
Jul 26, 2003

h_double posted:

A couple of Unity questions:


1) I'm using the First Person Controller for the player object (which is simulating a boat with an engine), and want to have separate acceleration and deceleration rates for forward movement. That is, going forward will ramp up to MaxGroundAcceleration fairly quickly, but when the forward input is released, the speed will taper off at a slower rate. I've looked at the CharacterMotor and FPSController scripts, which look like they ought to be the right place, but am not quite sure what to change.

Have you considered making the boat a rigidbody instead and just applying forces to it? It would make this process a lot less complicated since rigidbodies already have a drag element that you can alter.

Fox1
Apr 30, 2004

by Fluffdaddy
I need help with a (perhaps simple?) physics problem.

Corner collisions.



I'm using a very basic engine that can handle sprites and has collision detection. So far I have set up a collision detection for the ball and the rectangle, if there is a collision I have some code that determines what side of the rectangle is hit, if a side is hit make vX = -vX, and if the top or bottom are hit I make vY = -vY and this is ok so far.

I've read about making the corners tiny circles, but I have no idea how to implement this, I understand what a 'normal' is but again I don't know how to articulate this in to code (this engine is C++ fyi)

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!
Use the circle's normal instead of the square's normal for the deflection and you'll get the collision you want pretty effortlessly, I think. It's not as simple as just reversing a direction, but you can get rid of your reversing a direction code.

I always have to look up the math of deflections so I can't write the code for you without doing the same work you'd have to.

Unfortunately, once you get into this you're probably going to run into all the problems with what happens when objects are overlapping and stuff too.

roomforthetuna fucked around with this message at 17:03 on Mar 19, 2012

My Rhythmic Crotch
Jan 13, 2011

Stiggs posted:

This isn't exactly what I'm looking for, unless I'm misunderstanding which is fairly likely! I made an image to try and make myself clearer.



The top part is what's happening now. I'll click somewhere and the image will move in a straight line towards it while rotating. The bottom is what I want. If the image is facing left and I click somewhere to the right of it, I want it to have to do a U-turn because it can only travel forwards.

Fake edit: While drawing the image and writing this, I've been thinking and I'm pretty sure I can just perform the rotation like normal while applying acceleration in the forward facing direction until x = destinationX or something. I think I was overcomplicating it!
Try something like this:
code:
unitUpdate()
{
	calculate heading to destination
	rotate +/- based on new heading
	now calculate dx and dy and apply them to position
}
I do this, but I also check the very first heading calculation. If it's above a certain threshold, I have the unit rotate in place until it's facing the destination. Otherwise can drive in a really huge ark, which makes the navigation cumbersome.

h_double
Jul 27, 2001

SuicideSnowman posted:

Have you considered making the boat a rigidbody instead and just applying forces to it? It would make this process a lot less complicated since rigidbodies already have a drag element that you can alter.

Thanks; I'm not sure if I need a rigidbody, but you got me to consider that I was probably overthinking things by using a FirstPersonController, which has a lot of extra functionality I wasn't going to be using anyway. I'm writing a simple movement script with variables for forwardVelocity and rotationRate and it's easy enough to manage the necessary motion controls that way.


Another question: anybody know of any decent replacement water shaders for Unity Free, or suggestions for tweaking the built-in Simple Water? When the camera is close to the water, you can't see the wave ripples and it all looks like a flat single-colored plane.

Centripetal Horse
Nov 22, 2009

Fuck money, get GBS

This could have bought you a half a tank of gas, lmfao -
Love, gromdul

Stiggs posted:

I'd love to take a look at your AS3 code if you don't mind, I'm still getting a little stuck over here. :)

I'll dig it up when I get home, tonight.

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.
For the turning-arc-to-face-a-target algorithm, here's what I use:

code:
// IN:
// entity - the thing doing the chasing
// velocity - the current velocity (including speed) of the thing doing the chasing
// turningSpeed - degrees per second
// target - the thing we're chasing
// elapsed - frame time in seconds
// OUT:
// return value - the new velocity (including speed) of the thing doing the chasing
Vector GameHelper::GetChaseVelocity(const Vector &entity, const Vector &velocity, float turningSpeed, const Vector &target, float elapsed)
{
	Vector entityToTarget = target - entity; // Vector subtraction
	Vector entityTurningAxis = velocity * entityToTarget; // Vector cross product

	float cosine = Vector::DotProduct(velocity, entityToTarget) / (velocity.Magnitude() * entityToTarget.Magnitude());
	if (cosine > 1.0f)
		cosine = 1.0f;
	else if (cosine < -1.0f)
		cosine = -1.0f;
	float entityAngleToTarget = MathHelper::ToDegrees((float)acos(cosine));
	// If the resulting angle is too big (vs. the turning speed), cap it at
	// the turning speed
	if (turningSpeed * elapsed < entityAngleToTarget)
		entityAngleToTarget = turningSpeed * elapsed;
	else
		entityAngleToTarget *= elapsed;
	Matrix entityRotation; // Initializes as the identity
	entityRotation.Rotate(entityAngleToTarget, entityTurningAxis); // Kinda like glRotate
	return entityRotation.PostTransform(velocity); // Rotate the velocity
}
Possibly not the best way to do it, but it works for me.

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!
Appropriate turning arc to move to a target is rather dependent on the mechanisms involved, too - an Asteroids ship would get to a point behind it most quickly by turning on the spot at least half way before even starting to accelerate, and it would seem kind of dumb for it to follow an arc like the one depicted. A car has to be moving before it can turn, so it will have an arc that starts out moving away from the target (assuming it can't reverse) but its turning speed is linked to its wheel speed so you won't get the same sort of arc as you would with constant turning speed and constant acceleration - you'll get the same curve regardless of speed (also assuming no skidding). A person can turn so quickly that it would be daft for them to start accelerating before they're pointing the right way (but if they're already moving then a curve might be better than coming to a stop straight). Helicopter and aeroplane are different again.

HolaMundo
Apr 22, 2004
uragay

sponge would own me in soccer :(
I'm currently using Unity3D for 2d game development (using Sprite Manager 2) and wondering how to do an animated ray, the problem is it's length isn't fixed.

Basically I've got some pngs for ray animation and can tile themselves, so what I wanna do is draw this sprite from certain point to another with the texture repeating itself.
Stuff I've tried so far doesn't work and I'm really lost, any clues how to do this?

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Stiggs posted:

This isn't exactly what I'm looking for, unless I'm misunderstanding which is fairly likely! I made an image to try and make myself clearer.



The top part is what's happening now. I'll click somewhere and the image will move in a straight line towards it while rotating. The bottom is what I want. If the image is facing left and I click somewhere to the right of it, I want it to have to do a U-turn because it can only travel forwards.

Fake edit: While drawing the image and writing this, I've been thinking and I'm pretty sure I can just perform the rotation like normal while applying acceleration in the forward facing direction until x = destinationX or something. I think I was overcomplicating it!

I believe that proportional navigation is better than the "turn directly towards the target" method. It's especially better when the target could be moving. I think it's also better if you are accelerating. Edit: To clarify, you are still turning towards the target, but this method tells you how much you should turn towards it.

HappyHippo fucked around with this message at 23:27 on Mar 19, 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!

HolaMundo posted:

I'm currently using Unity3D for 2d game development (using Sprite Manager 2) and wondering how to do an animated ray, the problem is it's length isn't fixed.

Basically I've got some pngs for ray animation and can tile themselves, so what I wanna do is draw this sprite from certain point to another with the texture repeating itself.
Stuff I've tried so far doesn't work and I'm really lost, any clues how to do this?
I don't know about with Sprite Manager - I'm using cubes to mount my sprites, and you can do this by setting the cube's position and scale to make it the shape you want (and maybe rotation), then renderer.material.SetTextureScale("_MainTex",new Vector2(numberofrepetitions,0)); (or 0 first if you're wrapping it top to bottom). Where numberofrepetitions can include a fraction if you want, and is raywidth/spritewidth.

Centripetal Horse
Nov 22, 2009

Fuck money, get GBS

This could have bought you a half a tank of gas, lmfao -
Love, gromdul

HolaMundo posted:

I'm currently using Unity3D for 2d game development (using Sprite Manager 2) and wondering how to do an animated ray, the problem is it's length isn't fixed.

Is SM2 worth the $150? I ran through the demos a couple years back with an old version and it was a little buggy, but pretty cool.

diamond dog
Jul 27, 2010

by merry exmarx
I hear 2D Toolkit is better (and cheaper, too), but I haven't tried both.

Princess Kakorin
Nov 4, 2010

A real Japanese Princess
This is something that has been bothering me for awhile - whats the best way to handle drawing?
Should each sprite object have it's own Draw() function? Or should I give the Canvas object it's own Draw() function?
If I gave each sprite a draw function, it'd be a long chain of passing the Canvas object from the GameEngine down to the Sprite so that it could be blitted to the screen(GameStateManager.Draw(canvas) -> GameState.Draw(Canvas) -> Sprite.Draw(Canvas))
However, it'd give me more options as to how everything gets drawn.
Maybe I could have a pointer in each GameState that points to to the GameEngines canvas?

But, if I gave the Canvas object it's own draw function, it'd be a long chain of passing the Sprite from up from the GameState(GameStateManager.getState().GetAllSprites())), and I wouldn't have an easy time having different options(such as what if every sprite has a particle effect with it?)

I'm at a loss as to what the "best" way to handle this would be. Any suggestions?

dizzywhip
Dec 23, 2005

I have no idea what language or framework you're using, but typically when you have a pervasive object like a drawing canvas that needs to be used by just about everything, you make it accessible globally in some way. How you do that depends on your language.

In most class-based languages you'd probably define a static property or method that gives you the canvas object. Then in the drawing code for each sprite you could grab the canvas by doing something like Game.canvas or Game.getCanvas() or whatever.

And just to be clear, you want to have all of your drawing code inside of each of your sprite classes rather than doing all of the drawing in your global canvas object. The latter will get out of control very quickly.

Princess Kakorin
Nov 4, 2010

A real Japanese Princess

Gordon Cole posted:

I have no idea what language or framework you're using, but typically when you have a pervasive object like a drawing canvas that needs to be used by just about everything, you make it accessible globally in some way. How you do that depends on your language.

In most class-based languages you'd probably define a static property or method that gives you the canvas object. Then in the drawing code for each sprite you could grab the canvas by doing something like Game.canvas or Game.getCanvas() or whatever.

And just to be clear, you want to have all of your drawing code inside of each of your sprite classes rather than doing all of the drawing in your global canvas object. The latter will get out of control very quickly.

Whoops, should have specified. I'm using the SDL libraries with C++.
Is it safe to be using global variables? Everything I've been taught goes against the idea.
But, I guess I could make a global namespace that holds things such as gravity, Canvas, etc etc. I just won't like it.

dizzywhip
Dec 23, 2005

In general, yes, it's a bad idea to use global variables, but in certain applications they make sense. This is definitely a classic situation where they can be useful.

Even if you don't make the canvas a global variable, I would argue that by passing around a reference to it through a bunch of deeply-nested function calls, that object is essentially global anyways, just in a very roundabout and cumbersome way.

It's good to keep in mind that these kinds of conventions are often not set in stone. Here are some quotes from the first Google result for "why are global variables bad":

quote:

As with all HeuristicRules, this is not a rule that applies 100% of the time. Code is generally clearer and easier to maintain when it does not use globals, but there are exceptions.

quote:

When global variables represent facilities that truly are available throughout the program, their use simplifies the code.

Wikipedia actually mentions your use case exactly:

Wikipedia posted:

However, in a few cases, global variables can be suitable for use. For example, they can be used to avoid having to pass frequently-used variables continuously throughout several functions.

In games it's very common to make very widely-used objects like the player and the current level globally-accessible. Imagine needing to pass around a reference to the player to everything that needs to interact with it -- the code would become almost unmaintainable for all but the simplest games.

Anyways, this is all just a long-winded way of saying that global variables are fine if you know when and how to use them.

dizzywhip fucked around with this message at 07:44 on Mar 20, 2012

Bongo Bill
Jan 17, 2012

In most languages, standard output is global, right? Your canvas fulfills the same purpose as stdout, so it too should be accessible globally. (Though it isn't always idiomatic to simply declare it in global scope and call it a day.)

HolaMundo
Apr 22, 2004
uragay

sponge would own me in soccer :(

roomforthetuna posted:

I don't know about with Sprite Manager - I'm using cubes to mount my sprites, and you can do this by setting the cube's position and scale to make it the shape you want (and maybe rotation), then renderer.material.SetTextureScale("_MainTex",new Vector2(numberofrepetitions,0)); (or 0 first if you're wrapping it top to bottom). Where numberofrepetitions can include a fraction if you want, and is raywidth/spritewidth.

Great I'll try this and see if it works, thanks.


Centripetal Horse posted:

Is SM2 worth the $150? I ran through the demos a couple years back with an old version and it was a little buggy, but pretty cool.

It's a nice tool, however I'd probably try 2D Toolkit first (it's cheaper as someone said) and I've read it's easier to work with.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
In my opinion, making the canvas global is not the correct solution, but if it works for you go for it.

Personally, I like to have my game objects have a 'Render' method that, instead of actually rendering anything, creates a 'RenderInfo' object which contains all of the information that a separate class (GameRenderer, or something) can consume. For example, in an game I'm making, everything is rendered as a Quad, so the RenderInfo object consists of 4 vertices, texture, texture coordinates, 'layer', and a few other things. So, every frame, I iterate over all sprites and get a List of RenderInfo objects and pass those along to the GameRenderer, which does additional transformations based on the camera, viewport, etc. It also is in charge of sorting by layer and by texture to minimize texture switches, then draws back to front.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Orzo posted:

In my opinion, making the canvas global is not the correct solution, but if it works for you go for it.

Personally, I like to have my game objects have a 'Render' method that, instead of actually rendering anything, creates a 'RenderInfo' object which contains all of the information that a separate class (GameRenderer, or something) can consume. For example, in an game I'm making, everything is rendered as a Quad, so the RenderInfo object consists of 4 vertices, texture, texture coordinates, 'layer', and a few other things. So, every frame, I iterate over all sprites and get a List of RenderInfo objects and pass those along to the GameRenderer, which does additional transformations based on the camera, viewport, etc. It also is in charge of sorting by layer and by texture to minimize texture switches, then draws back to front.
This is probably the best solution. Part of why scene graphs fell out of favor is because of this kind of disparity: The data organization of your sprite set might not be ideal for rendering. They might not be 1:1 either, like you could have an object that's a composite of several visual sprites.

Unormal
Nov 16, 2004

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

The Radix posted:

I hear 2D Toolkit is better (and cheaper, too), but I haven't tried both.

I've been using ex2D for my spriting, it's simple and has worked well for what I've used of it so far, and it's on sale for like $15 right now.

a lovely poster
Aug 5, 2011

by Pipski
Is paying for plugins just something you should get used to for Unity? I'm surprised all these libraries cost money.

Unormal
Nov 16, 2004

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

a lovely poster posted:

Is paying for plugins just something you should get used to for Unity? I'm surprised all these libraries cost money.

I actually really like that there's some financial incentive for people to develop and support reasonably good quality packages that you can just download and use wholesale. Saves a lot of time writing dumb support libraries, and the creators get a little out of it. Seems like a win for everyone.

SuicideSnowman
Jul 26, 2003

a lovely poster posted:

Is paying for plugins just something you should get used to for Unity? I'm surprised all these libraries cost money.

Yes, that's always been my problem with Unity. It's great that they even have a free version of this tool but it's severely limited compared to the $1500 version. That and while there's some good free libraries, the best ones you have to pay for.

Shalinor
Jun 10, 2002

Can I buy you a rootbeer?

SuicideSnowman posted:

Yes, that's always been my problem with Unity. It's great that they even have a free version of this tool but it's severely limited compared to the $1500 version. That and while there's some good free libraries, the best ones you have to pay for.
If you don't want them, don't pay for them. They're unnecessary.

Unity as a base engine, even the free version, is quite fantastic. You don't need plugins to extend it, you can just write your own. For our last game, I wrote my own A* pathing algorithm, despite there being some plugins for that. If you don't want to write your own? Then, yeah, you pay for them.

... but if you have the money and are making a business of it, most of the plugins are very worth just buying instead of duplicating. They tend to be very cheap relative to what they actually do.

devilmouse
Mar 26, 2004

It's just like real life.

a lovely poster posted:

Is paying for plugins just something you should get used to for Unity? I'm surprised all these libraries cost money.

My thought exercise:

Will writing a system where a decent plugin already exists bring me joy or will I learn something from it? I'll probably write it on my own if so! Will writing my own take a while and be boring? Then I'll pay!

I imagine using Unity as a student is a very different thing than using Unity as someone with a job doing screwing around in my spare time. Paying $15 so I don't have to reimplement yet another drop-down console or $20 to have a reasonable tweening system? Done deal. Sure, I could do it for less, but as the goblins tell us, "Time is money, friend!"

That said, I'm often surprised at just how nascent the Unity marketplace is. Lots of basic things are missing as Good, Well-Implemented Versions. In the coming years, as more and more casual developers hop on Unity, I bet there's a fair bit of change to made in recreating age-old libraries in Unity.

Adbot
ADBOT LOVES YOU

Princess Kakorin
Nov 4, 2010

A real Japanese Princess

Orzo posted:

In my opinion, making the canvas global is not the correct solution, but if it works for you go for it.

Personally, I like to have my game objects have a 'Render' method that, instead of actually rendering anything, creates a 'RenderInfo' object which contains all of the information that a separate class (GameRenderer, or something) can consume. For example, in an game I'm making, everything is rendered as a Quad, so the RenderInfo object consists of 4 vertices, texture, texture coordinates, 'layer', and a few other things. So, every frame, I iterate over all sprites and get a List of RenderInfo objects and pass those along to the GameRenderer, which does additional transformations based on the camera, viewport, etc. It also is in charge of sorting by layer and by texture to minimize texture switches, then draws back to front.

Makes sense, but I think either I'm misinterpreting you or you're misinterpreting me. The canvas object is basically what it's name says it is: the surface where everything gets drawn to, the game window, whatever you call it. I couldn't think of any decent way to get the gamescreen from the GameEngine class down to the sprites, but I guess the best way would be to make the Canvas global.

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