Tag Info

Hot answers tagged

16

Here's a quick outline, off the top of my head, of an algorithm that ought to work reasonably well. First, calculate the direction the object is moving, and check whether it's closer to horizontal or vertical. If the direction is closer to vertical (horizontal), adjust the position of the object along the direction vector to the center of the nearest pixel ...


12

I'm currently making a game that has to run on a wide variety of display sizes and aspect ratios, and it hasn't been a very easy process. In addition, if you're making things in pixel art, and you want to keep the pixel art feeling while supporting many resolutions, you're walking into a world of pain, so be prepared. In my opinion, there are several things ...


11

This article gives some useful explainations, even if that's before 4.3 came out: If you’re going for the “pixel art” look then the camera’s orthographic size is of critical importance; this is the trickiest part of nailing 2D in Unity. The orthographic size expresses how many world units are contained in the top half of the camera projection. ...


9

The attenuation function you've got, att = 1.0 / (1.0 + 0.1*dist + 0.01*dist*dist) is a fairly common one in computer graphics - or, more generally, 1.0 / (1.0 + a*dist + b*dist*dist)) for some tweakable parameters a and b. To understand how this curve works it's helpful to play with the parameters interactively. This curve is nice because it approaches ...


8

Consider actually generating the scaled down versions at development time, and including them directly in the game as a resource. Do this with Photoshop or whatever tool you find creates what you like. Then have the game dynamically select the right art set appropriate to the current resolution. Here are a couple of reasons you might do this... Saves ...


8

Talking about the "best choice" is always difficult, as long as you did not specify the task that you intend to perform in all detail. But here are several aspects to consider. First of all: Java is not C. The memory management is completely different, so one has to be very careful when trying to apply insights from one programming environment to another. ...


6

Show What You Can Do When looking to start or join a team online, people are always interested in seeing what work you've produced beforehand. The work doesn't necessarily have to be done in a game, but it should showcase your ability to create game quality assets. Talk About What You Want To Do If you're looking to recruit people for a team, talk about ...


6

Depends on the game, if the game is single-player, let the user select a resolution, if they are happy for small characters, they can have it, if they want to feel connected with the game, they can use a lower resolution. Games like Civilization opt for this method. However, if you're building a multiplayer game, you're going to need a fixed resolution, ...


5

There are various scaling algorithms that are specifically crafted for enlarging pixel art for modern displays. They usually work with factors 2x or 3x and produce nice non-blurred and non-blocky results. Take a look at this Wikipedia article, which has many examples.


5

This is called mipmaping, It looks like you are missing out on mipmaping for your textures. this causes a huge impact on visuals. And when it comes to mipmaping Normals, Specular and other "information" textures, it gets quite tricky. the reason for this is that when objects gets further away, the gpu has to take this into account and calculate the ...


4

It is absolutely business-as-usual to decouple physics (and related ops like ray-based picking) from display values. Two common examples (I welcome any others as comments): OpenGL uses the float range 0.0->1.0 in x and y, thus abstracting display code from resolution (and thus, pixels). Box2D is also built for such decoupling. But having said that, it's ...


4

I noticed in the comments you want to make an Entity Class. This basically indicates you want all of your objects in the game for example your player, a building etc to share similarities. To do this you simply decide what are those similarities and put them in your entity class (for my example i will assume everything will have a position so X & Y and ...


4

From your link: Next, we're calculating the line offset. We're dividing the pitch by 4; the pitch value is in bytes, but we're moving four bytes at a time. It should be: void putpixels(int x, int y, int color) { unsigned int *ptr = (unsigned int*)Screen->pixels; int lineoffset = y * (Screen->pitch / sizeof( unsigned int ) ); ...


4

You're not working with bitmaps here. The graphics object you're using uses vector graphics. So basically you're painting a lot of rectangles to your mask... The only reasonable way to determine whether or not your mask is entirely filled would be to render it to a BitmapData (using BitmapData.draw) and then iterate through the pixels until you hit a ...


4

Found a slution from some resource. Go to Global Game Settings, then go to any platform spoiler(for example "Windows" or "Android"), there choose spoiler "Graphics" and put the mark "Interpolate colors between pixels" off. Have fun :)


3

In your main ApplicationListener where you create a camera object there will also be a resize method. If not override/implement it. It takes two arguments and when the window is resized these will be the dimensions of the newly resized window. Just set the cameras size to the new window size and call camera.update(); Should sort it! (I assume you are using ...


3

I will assume you are reading a 32 bit RGBA surface, which means each pixel will have 8 bit for Red, 8 bit for Green, 8 bit for Blue and 8 bit for Alpha(transparency). Pixels indices: Pixels are stored in an one-dimensional array, so you can't simply say pixels[x][y]. As they are stored in order from left to right and from top to bottom, determining an ...


3

In the pixel shader you could pass in a 256x256 Texture2D with the pallet colors all lined up horizontally in a row. Then your NES textures would be converted to direct3D Texture2Ds with ever pixel converted to a 0-255 index value. There is a texture format that only uses the red value in D3D9. So the texture would only take up 8bits per pixel, but the ...


3

Sure. Figure out which portions of the screen you want to render at what resolutions, and render them into FBOs of appropriate sizes. Once you have your different elements rendered into separate FBOs, you can then composite them together into the main framebuffer using glBlitFramebuffer(). Or alternately, if you don't want to composite them together as ...


3

You will need an active edge list, which contains a list of all polygon edges intersected by the current scanline. You will also need an in/out flag for each polygon on the scanline. The flags are toggled on/of as you cross an edge for a polygon. The rules are drawing for each pixel along a scanline are; no polygon flags are 'in', then draw background ...


3

I found this code which seems to do what you want : http://fvirtman.free.fr/recueil/02_03_10_resize.c.html With the nearest algorithm, we fill each pixel of the scaled image using the nearest pixel from the source image. This leads to many possible artifacts. With the linear algorithm, the goal is to look for each pixel of the scaled image where we are in ...


3

When the pending movement is perpendicular to the last movement (in screen space), ignore it and use the last screen coordinates. If that lead to stutter that's as bad as the staircase, you might try moving the sum of the pending and last movement. I think the problem lies in v < sqrt(2). v > sqrt(2) should always move at least a full diagonal, ...


3

There's not much you can really do about that for a general physics-based world. If all of your objects were moving along lines or specific circles, you could do something. But you're operating under actual physics. The object is where the physics puts it; you are simply drawing a pixel-based approximation of that location. It's generally something you have ...


3

If you don't really care about texture memory usage (and the idea of blowing an insane amount of texture memory to achieve a retro look has a kind of perverse appeal) you could build a 256x256x256 3d texture mapping all RGB combinations to your selected palette. Then in your shader it just becomes one line of code at the end: return tex3d (paletteMap, ...


3

In one of my voxel engines, the voxel block explosion was done by creating a defined amount of minature blocks at the explosion point, and applying physical properties to them, eg velocity and gravity. Then, set them at random directions, and draw them. So, the actual voxel model wasnt really being disintegrated, but the voxel particles gave that impression. ...


3

If you pretend a pixel is a square (see A Pixel is Not a Little Square), then the center of that square is the pixel coordinate. This is documented in Direct3D 9's rasterization rules (emphasis mine): Direct3D uses a top-left filling convention for filling geometry. This is the same convention that is used for rectangles in GDI and OpenGL. In ...


3

Simple linear algebra will provide you the equations needed to rotate any given point p by some angle about the origin: new_p.x = p.x * cos(angle) - p.y * sin(angle) new_p.y = p.x * sin(angle) + p.y * cos(angle) To instead rotate around some point other than the origin, say the point q, you first translate your point so as to shift the coordinate frame ...


2

What you're running into is that the overhead of calling a Windows API function (SetPixel) for every pixel is huge. Assuming you don't want to use hardware graphics capabilities at all (entirely-software renderer), what you really need to do is compose the frame yourself in your own buffer in application memory - which is really fast since there's no API ...


2

These are all good answers but nobody explained the reason why you need to access the pixels in the way you do. The pixel data is a one dimensional array. For a 10x10 screen, the following is how you can visualize the data being set up. // This is how it is actually setup unsigned int data[100]; // This is how people envision it being setup unsigned int ...


2

You found the right answer yourself - you will have to render things to an off-screen buffer and upscale it to any of the supported resolutions. This will be very easy since oldschool games didn't have anything better than nearest neighbor interpolation anyway. If you use GPU for this, it's possible to avoid a resolution switch (upscaling to large ...



Only top voted, non community-wiki answers of a minimum length are eligible