Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
DtrollMC

Quick Fun Library

Recommended Posts

Posted · Original PosterOP

Have been working on this the past few days, on whatever time I get off work. Some functions and parameters can still be improved, but it is definitely usable enough to show you all! It's a cool little Java library. There are 3 primary classes:

Tile

This is an interface which helps define a Tile object. Some concrete classes have been implemented, such as ColorTile and SpriteTile, but many more can be created. 

TileMap

A data structure for managing these tile objects in a 2D array (matrix). Comes with an iterator for iterating through the tiles.

TileMapPanel

This class is used to visualize the Tile objects. Since the tile interface defines a method paint(Graphics g, int gridScale), the TileMapPanel iterates through it's TileMap and calls the paint(g, gridscale) function on each tile.

 

All in all, this is a really young library, I have a lot of improvements to make, but it's fun to play around with, and I've thought of a lot of applications, so I thought it'd be cool to see what y'all come up with.

 

Here are a few quick examples:

 

package com.carvethsolutions.gridlib

import com.carvethsolutions.gridlib.tile.ColorTile
import com.carvethsolutions.gridlib.tile.SpriteTile
import com.carvethsolutions.gridlib.tile.TileMap
import java.awt.Color
import java.util.*
import javax.swing.JFrame

/**
 *
 * @project gridlib
 * @author John on 5/5/2018
 */

fun main(args : Array<String>) {
    val tilemap = TileMap(128)
    val r = Random()

    for (x in 0 until 128) {
        for (y in 0 until 128) {
            val color = Color(r.nextInt(256),
                    r.nextInt(256),
                    r.nextInt(256))
            tilemap.placeTile(ColorTile(color, x, y), x, y)
        }
    }

    val tmp = TileMapPanel(tilemap, 8)

    val frame = JFrame()
    frame.add(tmp)
    frame.pack()
    frame.show()


    val frame2 = JFrame()
    val tilemap2 = TileMap(32)

    for (x in 0 until 32) {
        for (y in 0 until 32) {
            tilemap2.placeTile(SpriteTile("./res/grass.png",x,y),x,y)
        }
    }

    val tmp2 = TileMapPanel(tilemap2)
    frame2.add(tmp2)
    frame2.pack()
    frame2.show()
}

 

 

w1X6Jh7.png

 

The GitHub for this library can be found here: https://github.com/JLCarveth/gridlib

 

 

 


NetBeans is cancer. 

NetBeans is cancer. 

NetBeans is cancer. 

NetBeans is cancer. 

NetBeans is cancer. 

NetBeans is cancer. 

Link to post
Share on other sites
Posted · Original PosterOP

glad to see the shitposts get all the replies...


NetBeans is cancer. 

NetBeans is cancer. 

NetBeans is cancer. 

NetBeans is cancer. 

NetBeans is cancer. 

NetBeans is cancer. 

Link to post
Share on other sites
On 05/05/2018 at 9:25 PM, DtrollMC said:

~ snip ~

Nice! Is that Kotlin?


My current build :

Hurricane Mk.I

  • CPU - Intel Core i5-4690K @ 4.6 GHz ~ 1.25V
  • Cooling - Corsair H60 2013 Edition
  • Motherboard - Gigabyte Z97MX-Gaming 5 (mATX)
  • RAM - 16 GB DDR3-1600 Avexir Core Series (Red LEDs)
  • GPU - XFX Radeon R9 Fury X @ 1100/500 MHz -24 mV
  • Case - CoolerMaster MasterCase Pro 3
  • SSD - 256 GB ADATA SX900
  • HDD - 1 TB Seagate Barracuda 7200 RPM
  • PSU - Corsair RM750 (750W 80+ Gold)
  • Display - LG 34UM67-P Ultrawide (Freesync)
  • Keyboard - CM Storm Quickfire TK (Cherry MX Red) + CM Masterkeys Pro S RGB (Cherry MX Blue)
  • Mouse - Razer DeathAdder 2013
  • Audio - Sennheiser HD598 SE with detachable mic
  • OS - Windows 10 Home Edition
  • VR - Lenovo Explorer Windows Mixed Reality Headset
  • Laptop - ASUS K501LX with i7-5500U and GTX 950M
Link to post
Share on other sites
Posted · Original PosterOP
19 hours ago, Fire Yoshi said:

Nice! Is that Kotlin?

It's mostly built in Java, however I do the test files in Kotlin just because it's so damn easy / quick. Will probably be porting over the current classes to Kotlin as I develop.


NetBeans is cancer. 

NetBeans is cancer. 

NetBeans is cancer. 

NetBeans is cancer. 

NetBeans is cancer. 

NetBeans is cancer. 

Link to post
Share on other sites
Posted · Original PosterOP

Recently added some abstract matrix data structures, and plan to add new types of viewers.


NetBeans is cancer. 

NetBeans is cancer. 

NetBeans is cancer. 

NetBeans is cancer. 

NetBeans is cancer. 

NetBeans is cancer. 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×