Skip to content

Instantly share code, notes, and snippets.

Vector2 pixelToTile (Vector2 mouseInput) {
//Tiles are what size?
if (tileSize == 0) {
tileSize = tileGrid[0][0].toUse.getWidth();
}
int x = Math.floor(mouseInput.x / tileSize);
int y = Math.floor(mouseInput.y / tileSize);
@poemdexter
poemdexter / LoadRoom.cs
Created November 25, 2015 03:41
method for reading in the json
private Room LoadRoom(int roomNumber)
{
Room room = new Room();
TextAsset roomAsset = levelsData[roomNumber];
Dictionary<string, object> hash = roomAsset.text.dictionaryFromJson();
int roomWidth = int.Parse(hash["width"].ToString());
int roomHeight = int.Parse(hash["height"].ToString());
// tile properties for cells
@poemdexter
poemdexter / MiniJSON.cs
Created November 25, 2015 03:37
JSON parsing in C#
/*
* Copyright (c) 2012 Calvin Rien
*
* Based on the JSON parser by Patrick van Bergen
* http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html
*
* Simplified it so that it doesn't throw exceptions
* and can be used in Unity iPhone with maximum code stripping.
*
* Permission is hereby granted, free of charge, to any person obtaining
@poemdexter
poemdexter / jenkins.css
Created November 16, 2015 22:37
Jenkins css
#jenkins-name-icon {
position: absolute;
bottom: 3px;
left: 132px;
}
@poemdexter
poemdexter / dungeon.cs
Created October 16, 2015 05:29
yet another dungeon generator
using System;
using System.Collections.Generic;
// from https://github.com/adonaac/blog/issues/1
public class DungeonGenerator
{
/** GRID OF CELLS **/
private Cell[,] grid;
private int gridWidth, gridHeight; // of grid
@poemdexter
poemdexter / forer.java
Created October 16, 2015 05:26
forer code 2.0
float xOffset = arrayWid * (t.width / 2) + Gdx.graphics.getWidth() / 2;
float yOffset = arrayHei * (t.height / 2) + Gdx.graphics.getHeight() / 2;
public void render(SpriteBatch sb) {
sb.begin();
for (int x = 0; x < tileArray.length(); x++) {
for (int y = 0; y < tileArray[0].length(); y++) {
Texture texture = tileArray[x][y].background;
int posX = x * tileArray[x][y].width - xOffset;
@poemdexter
poemdexter / crayola.json
Created September 24, 2015 04:28 — forked from jjdelc/crayola.json
Crayola colors in JSON format
[
{
"hex": "#EFDECD",
"name": "Almond",
"rgb": "(239, 222, 205)"
},
{
"hex": "#CD9575",
"name": "Antique Brass",
"rgb": "(205, 149, 117)"
@poemdexter
poemdexter / 1_DungeonGenerator.cs
Last active May 12, 2016 13:43
C# implementation of dungeon generation based off https://github.com/adonaac/blog/issues/1
using System;
using System.Collections.Generic;
// from https://github.com/adonaac/blog/issues/1
public class DungeonGenerator
{
/** GRID OF CELLS **/
private Cell[,] grid;
private int gridWidth, gridHeight; // of grid
@poemdexter
poemdexter / intellij-font-fix.md
Created August 24, 2015 17:25
Make IntelliJ render fonts correctly

To make IntelliJ render fonts correctly

-Dsun.java2d.xrender=true to ~/Library/Preferences/IntelliJ IDEAXX/idea.vmoptions

@poemdexter
poemdexter / dawnbringer.txt
Created August 22, 2015 23:05
dawnbringer 32
; paint.net Palette File
; Lines that start with a semicolon are comments
; Colors are written as 8-digit hexadecimal numbers: aarrggbb
; For example, this would specify green: FF00FF00
; The alpha ('aa') value specifies how transparent a color is. FF is fully opaque, 00 is fully transparent.
; A palette must consist of ninety six (96) colors. If there are less than this, the remaining color
; slots will be set to white (FFFFFFFF). If there are more, then the remaining colors will be ignored.
FF000000
FF222034
FF45283C