Have you ever wanted to create a perfect retro game, but had no ideas for what colors to use? Here, I found a color palette that resembles that of a backlit Gameboy, ready to use. simply take the RGB or Hex value, and insert it into your game. It's as easy as that!
Here is a full table of all the information you need:
Image | RGB | Hex |
---|---|---|
[0, 79, 58] | #004f3a | |
[0, 105, 74] | #00694a | |
[0, 154, 112] | #009a70 | |
[0, 181, 130] | #00b582 |
Here are some code examples for drawing a rectangle and changing it's color based on the palette. For simplicity, every example will use the darkest green. They may also use Libraries.
1) HTML/CSS
<!DOCTYPE html> <html> <head> <style> .rectangle { width: 100px; height: 100px; background-color: rgb(0, 79, 58); } </style> </head> <body> <div class="rectangle"></div> </body> </html>
2) Javascript
<!DOCTYPE html> <html> <body> <div id="rectangle" style="width:100px; height:100px;"></div> <script> document.getElementById("rectangle").style.backgroundColor = rgb(0, 79, 58); </script> </body> </html>
3) Python (TKinter)
import pygame pygame.init() screen = pygame.display.set_mode((800, 600)) running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False screen.fill((255, 255, 255)) pygame.draw.rect(screen, (0, 79, 58), (100, 100, 100, 100)) pygame.display.flip() pygame.quit()
4) Java
import java.awt.*; import javax.swing.*; public class RectangleColorChange extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(new Color(0, 79, 58)); g.fillRect(50, 50, 100, 100); } public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(200, 200); frame.add(new RectangleColorChange()); frame.setVisible(true); } }
5) C# (Unity)
using UnityEngine; public class RectangleColorChange : MonoBehaviour { void OnGUI() { GUI.color = new Color(0f, 79f/255f, 58f/255f); GUI.Box(new Rect(100, 100, 100, 100), GUIContent.none); } }
6) C++ (SDL)
#include <SDL.h> int main(int argc, char* argv[]) { SDL_Init(SDL_INIT_VIDEO); SDL_Window* window = SDL_CreateWindow("Rectangle Color Change", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_SHOWN); SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); SDL_SetRenderDrawColor(renderer, 0, 79, 58, 255); SDL_Rect rect = {100, 100, 100, 100}; SDL_RenderFillRect(renderer, &rect); SDL_RenderPresent(renderer); SDL_Delay(3000); SDL_DestroyRenderer(renderer); SDL_DestroyWindow(window); SDL_Quit(); return 0; }
7) Swift (SpriteKit)
import SpriteKit import GameplayKit class GameScene: SKScene { override func didMove(to view: SKView) { let rectangle = SKShapeNode(rectOf: CGSize(width: 100, height: 100)) rectangle.fillColor = SKColor(red: 0/255, green: 79/255, blue: 58/255, alpha: 1) rectangle.position = CGPoint(x: frame.midX, y: frame.midY) addChild(rectangle) } } @main struct MyApp: App { var body: some Scene { WindowGroup { ContentView() } } }
8) Kotlin (LibGDX)
import com.badlogic.gdx.ApplicationAdapter import com.badlogic.gdx.Gdx import com.badlogic.gdx.graphics.GL20 import com.badlogic.gdx.graphics.glutils.ShapeRenderer class MyGdxGame : ApplicationAdapter() { private lateinit var shapeRenderer: ShapeRenderer override fun create() { shapeRenderer = ShapeRenderer() } override fun render() { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT) shapeRenderer.begin(ShapeRenderer.ShapeType.Filled) shapeRenderer.color = com.badlogic.gdx.graphics.Color(0f, 79/255f, 58/255f, 1f) shapeRenderer.rect(100f, 100f, 100f, 100f) shapeRenderer.end() } override fun dispose() { shapeRenderer.dispose() } }
9) Ruby (Gosu)
require 'gosu' class GameWindow < Gosu::Window def initialize super 800, 600 self.caption = "Rectangle Color Change" end def draw Gosu.draw_rect(100, 100, 100, 100, Gosu::Color.rgb(0, 79, 58)) end end window = GameWindow.new window.show
10) Lua (Love2D)
function love.draw() love.graphics.setColor(0, 79/255, 58/255) love.graphics.rectangle("fill", 100, 100, 100, 100) end
I hope this helped you!
P.S. I know that including 10 languages was a little much, but once I started, I didn't want to stop (Gotta love GameDev procrastination)
Did you like this post? Tell us
Leave a comment
Log in with your itch.io account to leave a comment.
Thanks for the colors pallet. Do you have any more to suggest?
It is one of my two retro colors pallets, the other is green, red, blue, and grey
Thank you!