Here you can find the source of paintSprite(Graphics g, int x, int y, int[][] sprite, Color[] colors)
Parameter | Description |
---|---|
g | a parameter |
x | a parameter |
y | a parameter |
sprite | a parameter |
colors | a parameter |
public static void paintSprite(Graphics g, int x, int y, int[][] sprite, Color[] colors)
//package com.java2s; /*//from www. ja v a 2 s .co m * Copyright 2005 Patrick Gotthardt * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.awt.*; public class Main { /** * Paint the given sprite. The value of the sprite array is the color to pick from the colors * array. If it is 0, nothing is painted. The first color (index 0 in colors) is qualified as 1. * @param g * @param x * @param y * @param sprite * @param colors */ public static void paintSprite(Graphics g, int x, int y, int[][] sprite, Color[] colors) { for (int i = 0; i < sprite.length; i++) { for (int j = 0; j < sprite[i].length; j++) { if (sprite[i][j] == 0) continue; g.setColor(colors[sprite[i][j] - 1]); g.drawLine(x + i, y + j, x + i, y + j); } } } }