Hot answers tagged pixel
12
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 ...
10
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 ...
5
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 ...
5
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
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 ...
4
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.
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
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 ) );
...
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 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
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
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
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
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 ...
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, ...
2
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 ...
2
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 ...
2
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 ...
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 ...
2
Why not create a path under the alphabet that you can use as the drawing guide?
I don't know much about meshes, colliders or 3D models, but in Cocoa Touch or Core Graphics you could create a UIBezierPath of CGPath which and lay it underneath the image (whether you want it visible or not) and you could track the user's touch and drag along the path.
This ...
2
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.
...
2
Texture shaders actually does not exists on a GPU. They are just emulated in drivers. What it means is, that using them is very slow and you shouldn't use them in a real-time application like game.
If you looking for clearing textures just use clear function. If you want to create texture procedurally i do recommend binding it as a rendertarget and using ...
1
(both of my solution works only if you dont care about changing palletes on the fly using shaders)
You can use any type of texture and do just a simple computation on a shader. Trick is that you have more color information than you need, so what you will just get rid of information that you dont want to.
8bit color is in formar RRRGGGBB. Which gives you 8 ...
1
You'll need a (simple) shader.
Render the whole scene in color to an offscreen. Then run the whole output texture through a greyscale shader.
You can then run a pass using both textures as input along with the mask to select which source(s) to sample and how to mix them.
You could do it without the explicit greyscale pass, too. I think the extra pass ...
1
Hmm, I have just registered my account, but I can't access my original post. Can any moderator help?
Anyway, I was using 2D array so that I can store different "palettes" and swap between them. I will simplify the solution so that it uses a 1x4 and see if I can "toggle" between the 4 pixels with hardcoded values.
1
To draw a circle one pixel at at time, you can do something like this
int centrex=100,centrey=100;// centre of circle in pixel coords
int radius=50;
float two_pi=6.283f;
float angle_inc=1.0f/radius;
for(float angle=0.0f; angle<= two_pi;angle+=angle_inc){
xpos=centrex+radius*cos(angle);
ypos=centrey+radius*sin(angle);
...
1
You want to move the ball from side to side of the screen in the same amount of time. You can convert the screen resolution to [0.0, 1.0] (sometimes called screen coordinates to world coordinates conversion). Then you calculate the speed using that,
E.g: with one coordinates, you should expand it to use X and Y. You want the ball move from left to right on ...
1
This site contains an Introduction to SDL Video. You'll find the information there to properly set pixels.
I also highly recommend you download the official documentation from the SDL website: http://www.libsdl.org/docs.php.
The code on the site you linked to is quite hack-ish, and not very clear.
For one thing, it's hard-coded only to work with specific ...
1
Don't know if "everywhere" is true these days, but in good old days (on C64, PC and consoles like NES) the games ran in relatively low resolution (around 300x200 pixels), possibly with special hardware for tiled graphics and sprites.
Back then, it made perfect sense to measure distances and sizes in pixels, as everything was "solid" and there were ...
Only top voted, non community-wiki answers of a minimum length are eligible

