Displaying the Sprite Sheet

vanZeben · 110K views · 2012 · 19:57

Open on YouTube

Game programming & enginesIndie game developmentPython, Ruby & scripting languagestutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it when they are following this Java 2D engine tutorial and get stuck on sprite sheet loading, pixel arrays, or rendering bugs, and they cite it as the source of their code.

Recommended by 1 people across 1 different months, 2013 to 2020.

What it is

A 20-minute episode from vanZeben's Java 2D game engine tutorial series. It shows how to load the sprite sheet made in the previous episode into the game and render its tiles to the screen with a custom pixel-based Screen class.

What people said

Recommends george davies · 2013-01 · Stack Overflow · on “What is the use of the variable "MAP_WIDTH = 64" in the following code for rendering sprite sheets”

i'm wondering what "MAP_WIDTH = 64" does in the following code. It is taken from an episode in a series of videos on Java 2d game engine design and i have linked the video in question. The sprite sheet being used is a 256 x 256 .png with grids/tiles/sprites(?) of 8 x 8. The sprite sheet is only using 4 colours and they are setting each of these 4 colours to something else within the code. The following code is in the first minute of the video linked at the bottom. (some variables relating to the rendering omitted) I cant for the life of me figure out what is going on. Where does the 64 come from? The only thing i can see is that there are 64 pixels in a 8 x 8 grid, but then why multiply this

Cites Exikle · 2013-02 · Stack Overflow · on “Importing A Sprite from a sprite sheet”

Well i have been watching a couple of videos of youtube on how take sprites from a spritesheet (8x8) and i really liked the tutorial by DesignsByZepher. However the method he uses results in him importing a sorite sheet and then changing the colors to in-code selected colours. [this video] displaying the sheet [LINK] for the color rendering The code that i have made from watching his video is: package exikle.learn.game.gfx; import java.awt.image.BufferedImage; import java.io.IOException; import javax.imageio.ImageIO; public class SpriteSheet { public String path; public int width; public int height; public int[] pixels; public SpriteSheet(String path) { BufferedImage image = null; try { image = I

Cites TheDeadCrafter · 2016-11 · Stack Overflow · on “JFrame sprite sheet black screen”

So I have been trying to follow a tutorial But it isn't working. It is a tutorial on making a sprite sheet with JFrame. I could get other things to work, but for some reason this won't. It is supposed to display a tiled image, but instead it displays a black screen. Game.java package ca.colescheler.game; import java.awt.BorderLayout; import java.awt.Canvas; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.image.BufferStrategy; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; import javax.swing.JFrame; import ca.colescheler.game.gfx.Screen; import ca.colescheler.game.gfx.SpriteSheet; @SuppressWarnings("unused") public class G

Cites leekman044 · 2020-06 · Stack Overflow · on “problem with rendering a sprite sheet (pixels not rendering and shifting to the left)”

this is my first time asking a question on stack overflow. I've been following this [this video] tutorial on making a 2D game with java and have come across a problem... When run my program it renders my sprite sheet very weirdly: My JFrame: [LINK] his JFrame: [LINK] I have no Idea what is causing this problem but here is my code. i'm sorry if it is too long. game.java: import java.awt.BorderLayout; import java.awt.Canvas; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.image.BufferStrategy; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; import javax.swing.JFrame; import com.leekman.game.gfx.screen; import com.leekman.game.gfx