GithubHelp home page GithubHelp logo

ldurniat / berry Goto Github PK

View Code? Open in Web Editor NEW
19.0 5.0 3.0 6.96 MB

Berry is a simple Tiled Map Loader for Corona SDK.

License: MIT License

Lua 100.00%
tiled map lua isometric solar2d berry tile tilesets corona-sdk corona

berry's People

Contributors

ldurniat avatar outlawgametools avatar timothymtorres avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

berry's Issues

Fix label plugin

So while I was overhauling the plugin system I noticed something. The label plugin has many of the variables referenced incorrectly.

Not just that the map.extension property is not even used in Map:extend. I’ll fix them, but it may take me a day or two.

Separate Berry from Lime2DTileEngine fork

Unless you are planning to merge Berry into Lime2D later on at some point, I would recommend you make Berry a stand-alone repo. I’m also pretty sure the original author of Lime2D is inactive and wouldn’t be able to accept a merge even if that’s the route you want to take.

I would do this for two primary reasons:

  • Berry was rewritten from scratch basically. It no longer has much resemblance to Ponytiled or Lime2D. (Although I would def give them credit in the README)
  • Contributors for code (including yourself) get to have their commits appear in their profile. This doesn’t happen for repos that are forks.

This blog post has some really good information that goes into detail about forks.

You will have to contact GitHub support and tell them you want to detach the fork and make it a stand-alone repository.

Refactor map.image_cache

So a lot of data has been crammed into this table and I think it’s getting very crowded. It’s time to cleanup and arrange the data into sub-tables. Also I’m going to change the variable name from image_cache to cache because initially it was for only images but I started to put more and more data types in there. It currently contains the following data:

  • Texturepacker sheets and names
  • Tile GIDs for image sheets and image paths
  • Animation sequences for sprite sheets
  • Tileset info and image sheets

All of these types of data need to be put into separate tables and referenced appropriately.

Add TexturePacker support

So I'm looking to tackle this feature in PR #1 but some things definitely need to be taken into consideration.

The way a lua TP sprite is used is through the following methods:

local lua_sheet = require("path_to_TP_lua_file")  (ie. require("my-PC.project.image.lua"))
local image_file = "path_to_image_file" (ie.  my-PC/project/image.png)
local sprite_name = "name_of_sprite_you_wanna_use"

local sprite_frame = lua_sheet:getFrameIndex(sprite_name)

local imageSheet = graphics.newImageSheet( image_file, lua_sheet:getSheet() )
local sprite = display.newImage( layer, image_sheet, sprite_frame)  

Not too complex really. Although to implement this into Berry some consideration needs to be taken.

We need to require the lua_sheet somewhere and save it. Do the same with the image_file. The sprite_name will be used to locate the frame index of the sprite. Those three things are needed to add an object to berry.

If we add a addImageSheet method to berry, it should save the image sheet somewhere that is only used for texture packer sprites. Since the sprites don't have anything to do with gid, I don't think they should be grouped with Tiled image sheets, but it might be possible. Maybe have a variable like, map.TP_imagesheets or something. We also may want to save the lua file somewhere to map as well. (ie. map.TP_lua_files)

Once we have a method that adds our imagesheet our next step would be:

local imageSheet = map:addImageSheet(image_dir, lua_sheet)  -- returns an imagesheet

At this point I assume myself and other users who are planning to use this feature will have multiple texturepacker image sheets and sprites loaded. Therefore we need a universal lookup across all imagesheets to find the frameIndex for a sprite name. (Ie. if you load 3 imagesheets and lua files, we need to search for a sprite name across all of these) So we would need to add another method to berry getSpriteFrame. It would look like:

-- this assumes the imageSheet was added like so, map.TP_imagesheets[name] = lua_sheet

function Map:getSpriteFrame(sprite_name)
	local spriteFrame
	for name, info in pairs(map.TP_imagesheets) do
		spriteFrame = info:getName(sprite_name)
		if spriteFrame then return spriteFrame end
	end
end

Then if we combine all the above adding a sprite using Texture packer should be simple.

local imageSheet = map:addImageSheet(image_dir, lua_sheet)
local sprite_frame = mapt:getSpriteFrame(sprite_name)
local sprite = display.newImage( layer, image_sheet, sprite_frame)  

I will play around with coding this over the week, but my time is constrained currently. Adding these features turned out to be way more work than I initially thought!

Apply Tiled properties directly to tables

So I’m overhauling how berry does property management for all types of containers: Objects, Layers, Maps, Tilesets, etc.

My goal is to copy properties directly to their designated tables instead of having to do weird lookups. Going to try my best to remove the findProperty function as it will be deprecated and no longer needed.

Move example files to repo or folder

Another useful suggestion. Definitely should consider making the example map, Corona files, etc. all in their own repo or folder perhaps. The main directory should just be berry.lua, the plugins folder, and the README.

If the code is put into an example repo, it will have to constantly updated as Berry as fixed or improvements added to it. This may be time consuming, but probably not.

Add basic documentation

I noticed the doc folder is gone. Not sure if that was intentional or not, but I think the project could benefit from some basic documentation. You should also include documentation for what properties a object/layer/map table contains. This will be useful for when people are creating (whatever kind of) objects to look at a table they can reference.

Ie.

    local fake_object_json_data = {
      gid = 1075,
      height = 32,
      width = 32,      
      name = "foo",
      rotation = 0,
      type = "blah",
      visible = true,
      x = 0, 
      y = 0,
      properties = {},
    }

Add support for Lua map files

Tiled allows a user the feature to export the map as either a JSON or lua file. Seems kinda silly that a lua library doesn't support a lua format. With that said, I'm not sure how much work it would take to incorporate this feature.

Fix animations not working properly

So it appears that the animation code is broken. Not sure if it was like this initially or because of some changes I made earlier. Regardless, here is what is happening.

In the README.md it says it’s possible to animate a sprite with the custom property isAnimated for either an object or a layer. The object creation code checks for these properties successfully. The problem is that neither the object nor the layer contains the needed sprite data to animate the object. This is because when you use Tiled’s Animation Editor it exports all the animation data to the tileset. Thus, the object/layer needs to be linked to the tileset somehow.

Luckily it shouldn’t be too hard to fix. In fact, there doesn’t even need to be a isAnimated property at all. I can simply check if the object gid is present in the map.cache.animations table. If it is, then it’s an animated sprite automatically.

Maybe an older version of Tiled had different data structure for its animation stuff? That could be why it’s not working now.

Fix map example

Whenever I load level.json from Tiled I get this,

screenshot 1

I'm currently using Tiled v1.1.5 I think this problem is due to the images not being in the same directory as the json file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.