thelukester92 / swift-engine Goto Github PK
View Code? Open in Web Editor NEWAn entity-component-system game engine built in the Swift programming language.
License: MIT License
An entity-component-system game engine built in the Swift programming language.
License: MIT License
LGScene doesn't have to subclass SKScene. It can do what the LGSprite does, which is keep a reference to an SKNode and reference it as needed. This will make it easier to strip out SpriteKit completely if that were ever necessary, as well as keep things clean. LGScene could provide a cleaner entry point than "didMoveToView."
There is no need for these two systems to be separate.
Let entities optionally be assigned a string name by which it can be accessed later (useful in game logic, also could be used in scripting). Probably should assign entities an id within the scene and have a dictionary map names to those ids instead of to entities themselves.
Have not yet implemented static entities in the physics system. Should be easy, since the functionality exists for detecting entity-to-entity collisions (as dynamic collisions are detected) and resolving static collisions (as tile collisions are resolved). In fact, static entity collisions are already used by the dynamic collision resolution to prevent true collision chaining.
Instead of jumping into a big project right away, duplicate existing games like Snake, 2048, Flappy Bird, etc. as examples of what the engine can do and how it works.
Physics system currently only has collision chaining for static collisions. Dynamic collisions that should be chained are treated as static instead for performance. Dynamic chaining should be allowed (enabled/disabled by a Boolean switch).
The first rendered frame is displayed before entities have been positioned. Should position before rendering for the first time.
Like this:
LGSprite(color: UIColor.redColor(), width: 12, height: 12),
Similar to #23 for the physics system.
If the camera starts in an invalid position, it appears that nothing is rendered at all.
Implement collision masks, so something like this can be done:
physicsBody.collisionCategory = PLAYER
physicsBody.collisionMask = WORLD | ENEMIES | BULLETS
bulletBody.category = BULLETS
Not only does this eliminate a lot of unnecessary checks for the physics system, but it also eliminates checks in the trigger handler (#60) for something like this:
bulletBody.collisionMask = PLAYER
bulletBody.trigger = true
bulletBody.triggerHandler = { player in player.die() }
As opposed to having to make sure that the other entity in the handler is the player.
Remove func type() from LGComponent, only need class func type() now. The following code was broken in betas 1โ3 so type() could not be removed.
let component = LGPosition()
println(component.dynamicType.type()) // should print "LGPosition"
Not sure if it's working in beta 4 yet.
All sprites have to have states to display anything. Shouldn't need states if only a single frame.
Original code:
let entity = LGEntity()
entity.put(
LGComponent1(),
LGComponent2()
)
New code:
let entity = LGEntity(
LGComponent1(),
LGComponent2()
)
Don't create entities/component from tmx objects. but read them in so the scene can.
Create a system that horizontally tiles an image and scrolls it at different speeds than the main level for a parallax effect. May also want vertical tiling and/or parallax/scrolling.
It would be convenient to have a debug mode with a debugging overlay that shows physics bodies and sprite boundaries. Debug mode could also (optionally) have a slow-motion setting.
Lua library source code is not needed. Should replace with a pre-compiled binary so that:
Should be able to shift tile maps and tile layers as tiles go off the screen.
Swift won't currently allow implicitly unwrapped optionals to be checked against nil. This works:
var optional: String!
if optional { println("here") }
But this does not:
var optional2: String!
if optional && optional2 { println("here") }
This does not work either:
if optional != nil && optional2 != nil { println("here") }
The current workaround is a double negative. When Swift supports it in a more elegant way, the code should be changed. Here's the working sample:
if !(!optional) && !(!optional2) { println("here") }
(!optional converts the value to the logic value's complement, then adding ! in front of that converts it back to the actual logic value)
Implement a more complete directional collisions solution. Current implementation allows for entities that collide on all sides or only on top; want to allow entities to pick and choose the sides on which they collide.
Case in point: moving platforms. Need a way for something on the platform to be connected to the platform as it moves. Implement a mechanism generic enough that it can also be used to connect entities, so that, for example, a boss could be composed of several connected entities.
Every source file says "All rights reserved." Need to update to reflect the license.
Create a parser class to be able to generate LGTileMaps from .tmx files.
Rendering system doesn't do anything with rendering layer or z-ordering.
z-indexing works between layers -- now it needs to work between entities on the entities layer.
Inefficient use of textures. Sprite system pulls a new texture for every sprite every frame.
Create a way to reuse tile entities as they shift on and off the screen.
Previously "cloud" collisions; implement a kind of collider that only blocks in certain directions, like a moving platform only collides when the player is on top of it.
Because some systems are caching components, they don't handle removed/changed entities properly.
So that entities can be stored and loaded from files, implement a deserialization scheme that component classes can implement. One possible way is to register component deserialization methods in the scene based on a unique string. For example, this JSON could represent an entity:
{ "position" : { x: 12, y: 24 } }
The LGPosition
component could register for it like this in the scene:
registerDeserializer("position") { LGPosition.deserialize($0) }
And the result of deserialization would be this:
LGPosition(x: 12, y: 24)
Perhaps a Deserializable protocol could work, then registering is simply associating a string with a class. It would be nice if Swift let us use Types as Dictionary keys and values.
Assign entities global ids at the scene level. May be able to access entities by id this way, in addition to accessing them via pointer in the systems.
Followers work and are automatically added/removed to entities for moving platforms. Need to add the functionality required to make it work with other things, too, like a multi-entity boss. Physics system currently removes all followers from an entity if it is not colliding on the bottom with anything.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.