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
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!
I have a DirectInput question - when I "EnumerateObjects" on a gamepad device, the controls returned are named:
code:
"Extra" - this appears to be the slider which is broken.
"Rudder" - this seems to be the x-axis of the second joystick.
"Throttle" - this seems to be the y-axis of the second joystick.
"Y axis" "X axis" - these are the left joystick and work fine
"Hat switch" - the d-pad, also fine
"A button" "B button" "C button"
"X button" "Y button" "Z button"
"Left trigger" "Right trigger"
"S button" - all the buttons are fine
Rudder's guidType is GUID_RzAxis, and throttle's type is GUID_ZAxis, when to any sane person a second joystick would just be another X and Y axis. Do the GUIDs of controls have to be unique to that control within a device or something? (I realise GUID stands for global unique ID, but that must be to uniquely identify a control type, not uniquely identify a control - after all, two gamepads will each have a control with GUID_XAxis)

Is there some way a gamepad can be set differently within DirectInput before I enumerate its controls, so it won't assume it's for a flying game or whatever the hell it's doing, and will just treat its controls as the generic things they are? I would expect a control to be GUID_RzAxis only if it's a forward-facing twist-control, because that's when the control itself is a rotation around the Z-axis - I don't want my controller to be telling me that it wants me to be using an X-axis as a Z-axis-rotator.

I don't like its name being 'rudder' either - when I put control names in the configuration box, how is a player going to know that the X-axis of their second joystick is called 'rudder'? That's pretty unintuitive.

(Note: not using the action mapper at all.)

Adbot
ADBOT LOVES YOU

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!
code:
TileIndex[x][y]=
   ((Tile[x][y-1]==Road)?128:0)   //up
 | ((Tile[x+1][y-1]==Road)?64:0)  //upright
 | ((Tile[x+1][y]==Road)?32:0)    //right
 | ((Tile[x+1][y+1]==Road)?16:0)  //downright
 | ((Tile[x][y+1]==Road)?8:0)     //down
 | ((Tile[x-1][y+1]==Road)?4:0)   //downleft
 | ((Tile[x-1][y]==Road)?2:0)     //left
 | ((Tile[x-1][y-1]==Road)?1:0)   //upleft
Then you have 256 possible road tiles indexed by the sum of the numbers that represent road-adjacencies.
(Since you're not talking C, I should specify that | is a "bitwise or" and could be replaced with plus in this context if you'd rather.)
You might actually want fewer tiles since, eg. diagonal adjacencies aren't relevant if you don't have both the horizontal and vertical in that direction. But it's easier to just have 256 and make irrelevancies look like duplicates of the closest relevant type.

Also bear in mind you need to make sure there's a buffer around the edges of the map so you don't end up checking coordinates of -1.

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!
And if you're rendering with DirectX or OpenGL or anything like that, you need even fewer actual graphical tiles since you can just have 10 actual tiles (corner, straight, T, dead end, lot, lot corner entrance right, lot corner entrance left, lot side entrance, lot corner, lot side), and rotate the texture coordinates for the different directions.

Edit: or even 9, because the lot corner entrance could be flipped as well as rotated.

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!
Bitfields are fantastic for collision detection and physics, but horrible for pathfinding. For the purpose of a Worms-style game, bitfields are fine because you really don't need the AI to pathfind - you could probably just test-fire 50-odd randomly aimed imaginary shots and go with the best one. (More or less depending on the AI skill level, but testing 50-odd parabola on a modern computer would be near enough instant, and would already make a tough opponent.) The only concern then would be having the AI walk/swing/whatever competently. If I was doing this, I'd surely do it with bitfields.

(Also you could speed things up similar to OneEightHundred's quadtree but more simply [and correspondingly less effectively], by doing a mipmapping of your bitfields - but I really don't think it would be worth the extra effort unless your maps are so big that bitfields wouldn't be a good method anyway, which would be pretty big.)

Another way you could do it (which I've used for a different purpose), which might be better for very large maps, is with boundary-lines (run lines clockwise so a west-to-east line is 'floor' and an east-to-west line is 'ceiling') and some sort of sorted links to the lines so you're not constantly checking against everything (I used a loose grid where each square of the grid links to the lines that pass through that square). The coding involved in doing it that way is loving horrible compared to the simplicity of bitfields, though, and in most cases it's worse for pathfinding and worse for, well, pretty much everything except space.

Also of note - if your displayed maps are made of an image then you may not even need (or want) separate bitfields for collision detection, you can just check against the displayed map pixels - I believe it's faster to compare "is DWORD (y*width+x) of the image my transparent color" than to compare "is bit (x&31) of DWORD ((y*width+x)/32) of the bitfield set". (If the display map is solely in video RAM this is a bad idea - but if you're wanting to arbitrarily remove pixels whenever there's an explosion then you'd be wanting a copy in system RAM for that editing anyway, so you might as well be keeping a copy in system RAM the whole time so that a change only has to copy it one way.)

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!

roomforthetuna posted:

Another way you could do it (which I've used for a different purpose), which might be better for very large maps, is with boundary-lines [...]
I forgot to say that the other advantage of this is that it more closely resembles what you'll need to do if you want to transition your stuff to 3D, because bitfields really won't work out in 3D. Minecraft-style notwithstanding.

But seriously, if you can do what you want with your bitfields or pixel-checks, do do it that way, because it is at least one and a half metric fuckloads easier.

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!

quote:

My problem is that I'm absolutely terrible with (OO) design and I usually either
a) Never get started/get lost in the design
b) Start without a design and get stuck somewhere and have to rewrite loads of code
Total rewrites and horrible kludges are actually pretty common. That's not to say it's okay - if you can avoid it, do - but I've come in to several professional team projects where the code was already a tangled disaster area, it's pretty much to be expected in game dev.

A great design is great and all, but at some point you just have to suck it up and work with/around the flaws that turn up in your design as you go. The art is in corectly determining when that point is.

I've found that, for me, the design 'pattern' that works best is to structure everything like a tree - I have a "game" object that contains everything else related to the game contents, and an "engine" object that contains all the DX/whatever functions and object management. Within 'game' I have a 'screen' that contains all the features of a menu screen or game screen (the screen pointer changes to a new object, kind of like you might do with creating a new window in normal Windows programming). Also like Windows I have lists of button objects and such contained within the menu 'windows', almost as if I was reimplementing all of the Windows GUI from scratch.

The reason I say it's like a tree is that you can basically get to *anything* game-data-related from the single 'game' pointer. Ideally you don't want to have to tunnel down like that, it's bad like global variables, but what it means is that when you come to write something later and realise you don't have a good interface for it, and you only want to do it in one little case anyway, you can always bodge out the data you want. Also it means you can pass groups of data to functions, eg. my current project has a 'room' object within 'game', and a list of 'things' within 'room', where 'things' are either players, exits or objects. It makes it easier to write functions that act on stuff within the room, such as a collision detection functions - you can pass the room pointer, rather than the list. And then when you later realise you also want a room map that isn't made up of 'things', like a heightmap or whatever, your collision detection function doesn't have to have its prototype changed to take more parameters.

As I said in the first place, this isn't perfect and tends to make the code a little tanglier than necessary, but it's the balance between the sins of "messy" or "too neat to be usable" that works for me.

Edit: another advantage of this structure is that it makes it relatively easy to back-access stuff from plugin DLLs and the like.

roomforthetuna fucked around with this message at 01:24 on Aug 26, 2010

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!

Internet Janitor posted:

If the lantern is basically just a constant circle of illumination centered on the player, couldn't you precalculate a "mask", representing the light added to tiles?
I think he was intending the light to fade up as you move across your tile, though that was unclear. Even then, if you wanted to you could precalculate a lookup table of masks.

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!

Internet Janitor posted:

roomforthetuna: Sure, or just do a simple tween from whatever the background illumination level is to the sum of the mask and the background.
No, I mean, even if there is no background illumination, I think he wanted it such that... well, let's say a tile is 32x32, if your lamp is at 15,15 on tile 0,0 then the light on tile 1,0 would be less bright than if you're standing at 29,15 on tile 0,0.

Just a single tile-based lighting mask wouldn't be enough to cope with those 32x32 possible lighting states per tile. But you could do it as a small lookup table of lighting masks.

(All of which is still moot because what he wanted was simple enough that it almost certainly wouldn't be worth precalculating anyway, even if your processor is from 1982.)

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!

Internet Janitor posted:

Take another look at my code-
code:
float brightness = RAIDUS - Math.sqrt(x*x + y*y);
The mask I'm generating incorporates the distance of each point from the origin at (RADIUS,RADIUS)- The mask is then laid on top of the player's position to generate a circle around wherever the player might be.

If I was raytracing to take obstacles and shadows into account, it's true that a single lookup table would be insufficient.
I'm not talking about shadows or anything. Your lighting mask has a resolution of one tile, is what I'm saying, so if you're standing on the left side of the tile you're on, the lighting pattern your mask will make is identical to if you're standing on the right side of the tile, even though in the latter case the light source has moved closer to stuff to the right. If he wants the lighting to change whenever you move (which it would, in his current method), then your method doesn't do that, it only changes whenever you move across a tile boundary.

So I was saying that in order to duplicate the effect he currently has, but using precalculated values, he'd need a lookup table of precalculated masks that chooses an appropriate mask based on the light's position within the tile it's on.

(None of this is true if his movement method resembles Nethack, with no steps smaller than a tile.)

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!

Bob Morales posted:

What's a better way to lock my game to a certain frequency other than SDL_Delay()?

It seems like my keypresses are getting dropped if you're in a delay call.
You probably need to be getting your keypresses a different way. Windows does messages, DirectInput does buffered events, I don't know what SDL offers, but immediate-mode "how's the keyboard right now?" functions are not good for anything that needs to catch short-lived keypresses.

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!
Problem I see there - if you pressed "left, left, left, left" within one frame, only one of them would do anything. Or if you pressed "left, left, left, right" you'd come out of the PollEvent loop with just "direction==BZ_MOVE_RIGHT" and all the lefts would be lost. And if you pressed "left" and then unpressed "left" in one frame, you come out with "direction==BZ_MOVE_NONE".

Your treatment of pressing up appears to be alright though.

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!

Bob Morales posted:

I haven't looked at it in a while, I'm not sure why I split it up to handle 'up' differently.
Probably because you were wanting holding to work on left/right/down, but not for rotating. If you put the movepiece inside the loop then you'll get all the directions working but only if you tap them, unless you also do the 'direction' thing you're doing now. (And if you do it with both without some fiddling you'll have difficulty not moving two squares at once.)

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!

Your Computer posted:

Another thing I wonder about is distortion. I made a tall box and positioned it down the y-axis but it didn't get distorted no matter where I positioned it :sigh: Since I'm going for the GTA 1-look I want the perspective to be distorted towards the viewer so you can view down the sides of the buildings. Am I positioning the box wrong or is it not tall enough?
I could be wrong, but I think in order to get noticeable distortion you'd need the box to be segmented. If you're just rendering a rectangle with 4 corners (the side of the box) it'll always be just a trapezoid on screen, any distortion could only be evident from movement not in a still image, but if you're rendering a series of rectangles going into the distance (in a distorted lens) then the trapezoids can be calculated as having different angles, giving you the curved distortion I think you're looking for.

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!
I have a question that should be pretty simple - what's the best (or a good) way to make a color-configurable object in 3D, such that you can have ten of the same object with different colors and without ten duplicates of the model and without changing the vertex data between renders?

For example, say I wanted to use a flag object with a fixed pattern but three user-configurable colors. I figure one way would be to split the object into three sub-objects and render them each with different colored lighting. Is there a better way than that?

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!

OneEightHundred posted:

Most games that do this have separate texture overlays for colorable parts.

For things that are color-tinged rather than a solid color, you can avoid using an alpha channel by premultiplying and treating the colorization layer as additive.
Sorry, can you give me a bit more detail about that? I mean, what would the vertex format be like for an object with three colorable parts using this method? Or does it still involve splitting the object into three sub-objects, and just coloring with a texture instead of with changing the light[s]? (If it's that, what makes that better than changing the light[s]?)

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!
Still not sure I'm getting how this works - what if you have ten guys with indepenently colored shirts, pants and hats? Would this involve rendering with basetexture and three other textures for each object? And if so, is that really going to be quicker/better than rendering it as three or four objects with only one texture each?

Also not getting how you'd do shirtmasktexture*shirtcolor - is shirtcolor being set as a variable in a shader or something? (So far I'm still using the old FVF so I'm not really sure what you can do with shaders.)

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!

OneEightHundred posted:

Coloration masks are single-channel so you can stuff up to 4 of them in the same texture.
Ah, I see what you're saying. Pixel shader magic.

quote:

Also FVF is obsolete as of D3D9, having been replaced by vertex declarations, which are better in every conceivable way.
Yeah, I have three reasons for still using FVF - one, it's what I wrote the engine to use the second time I rewrote it, and it seems silly to rewrite it again if I don't desperately need to, two, my target platform is "somewhat outdated machines and up", and my previous was-high-end laptop couldn't cope with a lot of shader stuff - I figure I'm pretty safe on the requirements front if I continue to use DX9 era stuff, and three, time spent learning to use shaders would be time spent not working on the actual game. Though I do occasionally find myself wishing I was using some of the vertex declaration stuff just for ease of handling the raw data!

Sorry if that sounds ungrateful, I do appreciate the advice and am certainly filing it away as a thing you can do with shaders that I didn't know about (especially sneakily slapping four 'grayscale' masks into one texture).

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!

OneEightHundred posted:

If your target minimum is DX9, you should be using vertex declarations, not FVF.
I was aiming for a minimum of "Direct3D 9 Drivers without Pixel Shader Version 3 Support" (as a piece of Microsoft documentation calls it), for which the requirements for using vertex declarations include that the declaration must map precisely to an FVF. Is this a model not worth supporting any more? (Again, this is what my previous was-high-end-at-the-time laptop was capable of.)

Eh, just checked my girlfriend's new-low-end laptop and it supports DX9 and puxel shader 3, so I guess it probably would be okay to stretch my low-end support up that far.

That said, I'm very unlikely to need or want any of the really clever stuff for my project - it's pretty much comprised of 2D stuff (some of which is made of basic 3D to produce a "Flashback" sort of look). As such I barely even need texture mapping (except as used for sprites), and certainly bump mapping would be ridiculous in this context.

Edit: But I should probably learn shaders anyway because my backburnered project will certainly want some of that prettier-looking stuff.

roomforthetuna fucked around with this message at 18:52 on Oct 28, 2010

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!

haveblue posted:

Put it this way- anything you are currently calling glTexEnv or glActiveTexture to accomplish (I forget what the DX fixed-function equivalent to these are) can be done much more cleanly and easily with a shader.
I don't know the GL stuff at all, so I don't know what would be equivalent. But I think the DIRECT3DDEVICE9's "SetTexture" function is the only function I use that has 'Tex' in the name. Ah, a quick grep reveals also "SetTextureStageState", is that the one you mean? I could see that one being superceded by shaders.

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!
I would say (as others have implied but not made entirely clear) that if you're doing your game data in XML or JSON, you might as well do your save files in the same structure. It seems silly to me to implement serialisation for a thing when you're already using a data structuring library of some sort, and you'll have a much easier time debugging a human-readable save file! (Unless you strongly object to people cheating by save-file editing too easily.)

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!

hayden. posted:

From what I've read online there's really no way to prevent decompiling pretty much anything. If this is the case, though, then why don't we ever see people decompiling games and modding them? Are these large scale multi-million dollar programs just too complex for a few people to do this on their own?
Decompiling doesn't really give you readable readily-workable code - there's no human-readable function names or variable names, no comments, it doesn't even turn into the same actual code - it's not much different from trying to work with the (million lines of) raw assembler code.

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!

Orzo posted:

Although I prefer composition over inheritance, it's also a design smell when you have an interface where implementors have half of the methods unsupported. For example, let's say IEntity has an UpdatePhysics method, a GetRenderInfo method, and a CheckCollision method. If you have an entity with no collision (say, a particle effect), you're now performing a noop on CheckCollision. Or if you have an invisible wall, now you're talking about returning a NullRenderInfo, or something similar, on GetRenderInfo.
How would you do it instead? Have the manager have separate lists of objects-that-can-collide-and-don't-render, objects-that-can't-collide-and-don't-render, objects-that-can't-collide-and-do-render and objects-that-can-collide-and-do-render (and double the lists again for every other trait that can lead to an unnecessary function call)?

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!

Zerf posted:

I think his concerns are legitimate, you don't want to execute function calls if they just nop. You have multiple options to this problem though, set a state flag on which updates to run for each entity or keep objects which needs physics objects in one list and renderable objects in another(and if both are needed, in both lists). One list for each state permutation seems like worst solution you can come up with, but I think we all agree that it's not an option.
Yeah, but the point is if you're doing it that way then you'd still want a generic entity object that encompasses all the behaviours, because you want to be able to store all the things in a single list, even if you're making separate 'handling' lists or having behaviour flags. Because if you don't have such an underlying object then what you end up with is the stupid thing I mock-suggested.

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!
To me it looks like (unless you have tens of thousands of objects active at one time) the very small efficiency loss of calling a virtual function that just returns immediately for objects that don't render or don't do physics is well worth it for the sake of simplicity versus the tangle you end up with if you have three or more distinct sorts of objects all cross-referencing each other. With the "single object, null interfaces for things it doesn't do" model you don't have to worry about reference counting on the transformation objects (or however else you were planning on dealing with cleaning up an object that's referenced from two or more places at the appropriate time), and it's not like the null function overhead is pure cost - it's partially offset against the management costs of dealing with the multi-referenced stuff, that you don't do.

But mostly it's the simplicity that seems like the big benefit.


vvvv I can't think of any way you could manage a tangle of mixed types cross-referencing each other more cleanly and simply than you could manage a single set of objects with the same available functionality some of which is just blanked for objects that don't care about it. Though I could see maybe an argument for the objects having some sort of more C-like behaviour, wherein some of the functionality might be set per-object rather than per-class so that you can have any combination of physics A or B and rendering X or Y without having to do any multiple inheritance malarkey.

roomforthetuna fucked around with this message at 00:22 on Nov 14, 2010

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!

Vinterstum posted:

The point is that unless you have experience with a couple of game projects already (your own, or in a team, whatever), thinking up base engine designs is about as useful as working out a football strategy without ever having watched an actual football game. It's starting out in completely the wrong end of things, and you'll probably end up with something which just isn't going to be a good fit for an actual project and will need to be redone anyway.
This is true even if you've already done things before. My experience has been that if I just start working with a lovely off-the-cuff design and rework it as necessary, I generally end up doing less work overall than if I try to work out a good design in the first place, and I'm a lot less likely to just get sick of it and quit because of making visible progress.

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!

OneEightHundred posted:

There isn't a whole lot of discussion on it because it really hasn't changed all that much since the late 90's, aside from the proliferation of lag compensation which basically always follows either "trust the client" or "try performing the action based on where things were at a previous point in time."
There are other options and considerations too, it all comes down to what sort of a setup is involved. There's the MMORPG "client sees what they do when they do it, other clients see an interpolation of that and what they would see if the same instruction had been given when they received it" method, useful in non-combat MMORPG settings where the accuracy of your current position is less important than not looking like everyone's teleporting around.

And there's the unusual method I'm using for the non-MMORPG parts of my game, where it's a mesh of peers with a synchronised timer rather than a server (so there's less lag, and MMORPG-style instant response for your own actions), though that's really a subset of "try performing the action based on where things were at a [not necesarily previous] point in time". Still, it's a different consideration.

There's also considerations of whether you have one giant scalable server or some sort of much simpler lobby that spawns mini-servers, which again depends on your goals.

Unfortunately I can't recommend any books or articles, because I pretty much hodgepodged it together from random gamasutra articles and manpages. At a lower level, you also need to consider what you're using - DirectPlay, some library like libevent, raw C sockets? If you don't send everything through a server how are you planning to deal with masqueraded networks?

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!

Sagacity posted:

I don't want to exclude any devices that don't support Flash.
Isn't that pretty much just iPhones anyway? And the Biolab Disaster page says it doesn't work adequately on iPhones. So you might as well just use Flash.

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!

Sagacity posted:

Well, yes, but that's a target audience I don't want to ignore :)
Which is why I went on to say that your plan to use HTML5 seemingly ignores iPhones anyway so is a silly idea.

(Hasn't someone made a Flash compiler that makes an iPhone app out of a Flash thing? Won't be in a webpage but will be supporting iPhone, if you can do it that way.)

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!

Senso posted:

Well, Flash works on Linux. As does HTML5. As do most Java games. There, you've got 95% of browser games covered running on Linux.
Would the iPhone browser support Java games? If so, that would probably make it the best option for Sagacity, apart from the whole "it pretty much sucks to work with compared to Flash" thing, but I'm sure that would have been true of HTML5 as well.

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!

Orzo posted:

I suppose the easiest technique here is to write a function that, given the position of the 'Top Left' and 'Bottom Right' vertices as anchors, and a rotational value, calculates the final Position (x,y) and Scale (sx, sy) of the new shape. I'm going to see what I can come up with, but my math is a little rusty here, does anyone know a way to do this easily? Or perhaps a better technique than what I'm suggesting?
The easy solution to me (probably not the fastest but it's for an editor so who cares) would be to take your 'worked on' coordinates, offset them such that the opposite corner or hotspot or whatever your anchor point for scaling is is effectively (0,0), then rotate your working coords by the inverse of your current rotation, and that'll give you an x,y that's the new scale factors (possibly after you divide by the original width and height, depending how you're working).

As for the final position, that depends how your objects are anchored - center, a hotspot, the bottom left (untransformed) corner? Regardless it should be pretty easy to get the new coordinates given that you have your worked-on corner's coordinates, a scale and a rotation. It sounds like you might still need to decide on how a rectangle is anchored, which would be your first priority.

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!

Orzo posted:

The anchor is always the center of the rectangle. Thanks for the input, seems like the solution to every problem is 'convert it to local coordinates' and work from there. Any other suggestions are welcome, I suppose I'll mess around with this on paper.
Well if the anchor is the center when you're scaling as well then you won't need to get the position out from your function, because that won't change - only sx and sy will change. Probably still easiest to convert to local coordinates first to get your new sx and sy, though.

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!
If that's how you choose to do it, sure. Doesn't seem like a great idea to have objects anchored by their center in every context except scaling, though.

My way, if your rectangle was (0,0) - (4,4) with no rotation, if you drag (4,4) to (8,8) then the new rectangle would be (-4,-4) - (8,8)

The downside of my way is you can't scale by a single pixel, the upside is you get a consistent interface where rotations, scalings and positionings are all based on the center. (And it's marginally less effort to code because it's consistent.)

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!
By "except scaling" I mean when you rotate the thing in the editor it's going to be rotating around the center point. When you move it, you're going to be moving it by the center point. When you scale it is the only time you're going to be interacting with it as if it's not anchored on its center point.

But if you don't think your users will like it scaled from the center then don't scale it from the center, that's fine. I don't know what sort of entities you're considering - for me, I would rather game-monsters and other such moving objects scale from the center, but if I was making floors and things I'd probably want them to scale from the ... hell, I don't know, nothing really makes consistent sense for floors, because you'd want them to anchor from the other 'surface' side, while moving the surface, but that would give you no interface for thickening a piece of floor. So I wouldn't care between center or opposite-corner scaling, they'd both be equally frustrating.

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!

Orzo posted:

You make a good point, but indeed this is primarily for floors, walls, etc. I want to easily be able to drag vertices and have them snap to the grid, but I don't want to change a perfectly good data model.
Are you really sure you don't want to make the entities arbitrary quads for that? Most often when you're making a game floor you really want to be able to skew a lot more than you want to rotate, as in the shape
code:
     ____
    /
___/ ____
    /
___/
Rotating for an angle-floor like that gives you overlap at the top and a wedge-gap at the bottom, where skewing would work fine. (But of course, again, I don't know what your maps are like, rotation will be fine if it's mostly open space.)

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!
Fair enough, good to see you've considered it, and you're right that (for steep slopes at least) dedicated shaping sprites will look a lot nicer.

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!

HappyHippo posted:

Another solution would be to have every unit remember what team it's on, but that lets bugs creep in because it's possible for the program to be in a state where the unit thinks it's part of team A while team A doesn't think it owns the unit. If I'm careful this won't happen, but the possibility is there, especially with the unit - tile relationship and the units moving around and dieing.
Isn't it a worse bug to have team A not think it owns the unit when it actually should, and that's the only data on the subject? If your data isn't being updated properly then bugs can creep in even if you only store the data one way.

It does give you more opportunity for bugs if every time something updates it has to be updated in five different places, but you should be boiling that update action down into one function anyway.

Also, it seems weird to me to have teams bother to remember what units are on them - when do you need to do an action on an entire team? Is it really critical that such a lookup not be a mere 6 times slower [do you have 6 teams?] It makes a lot more sense to me to have the unit store what team it's on, because that's the way round you'd be needing to check most often. (eg. when you click a unit, you'd first find the unit hopefully from some sort of location-based lookup, then you'd need to know what team it's on.)

The only reason I can think of to have the team store a list too is if there's a big performance saving during rendering by rendering all the guys with color scheme A first then all the guys with color scheme B, saving on changing a setting back and forth - and I really don't think the performance loss of just going through the whole list of units 6 (?) times, once for each color, would be that bad. (Unless you have thousands of units per team.)

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!

Elos posted:

Can someone with experience tell me how wrong my approach is and what's the 'right' way to do this tile stuff? Any helpful tutorials?
First, if it's running adequately the way you're doing it, you don't really need to worry about it. Performance improvements are for performance problems.

But if you're wanting to do it better anyway as a learning thing, a vertex buffer object is basically a vertex array that's stored on the graphics card so it's a lot faster. The only thing more complicated about it is that you have to lock it to write to it, and you're a lot better off not trying to read from it. Well, and, for edge cases and maybe not in Java, you have to be able to repopulate the whole buffer if it gets dropped for some external reason. So there's some management complexity, but not really any more *usage* complexity.

However, you're saying that the vertex array is also too complicated? Can you draw two or three tiles with the vertex array? Because if so, drawing 3072 tiles is really no different! Though ideally you'd probably break it down into smaller blocks of tiles, like display-sized blocks, and only render the 4 blocks that intersect the screen. With 3072 tiles, much like with your original setup, you don't really need to add the complexity when it'll work fine to just render it all as one block of vertices mostly-offscreen.

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!

Elos posted:

I'm thinking something like

1) Get the tiles that are visible on the viewport
2) If nothing has changed since last draw use the old arrays
3) If something's changed make new arrays out of everything on the viewport
4) Draw

Should be a lot faster.
Yeah, that's pretty much it, unless the viewport moves a lot and the tiles don't change much. If that's the case then you'd want to pre-set either one big buffer or a number of smaller buffers (possibly as subsets of one big buffer) so you can mostly just render a block of tiles and hardly ever have to change the buffer contents.

If you have things that move over the tiles, like a player-character, then ideally you want each of the sprites to have their own little [section of a] buffer, and move it around by changing the transformations rather than by changing the vertex coordinates. The goal when using vertex buffers is to change their contents as little as possible. (If someone knows better please correct me if I'm wrong on this!)

In fact, if the tiles change a lot you might even be better off treating them as sprites (with permanent vertex buffer) rendered with transformations to the position of each tile rather than as one big vertex buffer that you change. (Again, confirmation or denial from someone who does performance stuff more than 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!
I'm not sure I understand your complaint - Unity is too easy?

Is there something about your game idea that you feel Unity can't do? If there's no part it can't do, and the performance will be fine (which obviously it will for a turn-based game), and you find it easy, then surely the engine you should use is Unity?

I was eyeing Unity for my next project, but since I want to use a custom input device I suspect I'd need the expensive super-pro version that supports custom plugins, which is an unfortunate limitation that counts against it for me, but I don't see anything like that in your idea.

Adbot
ADBOT LOVES YOU

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!
Ah, I haven't actually tried Unity myself, so yeah, I agree that a drag-and-drop level of easiness would be pretty disturbing even if the output is perfectly fine. I'd also be a little afraid of 50MB of download required for a plain Tetris clone that should be measured in kilobytes, based on that. Since you've played with it, would that fear be justified? Are your tutorial binaries large / large DLLs required?

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