Kro Engine

Monkey Programming Forums/User Modules/Kro Engine

cageInfamous(Posted 2013) [#1]
Kros Engine
This is my engine that I built for a game I'm working with. Though there is A LOT this engine features, I'm just going give a few details about it because I'll be releasing it soon (probably this week).
The main features about my engine that are great is it's powerful, fast, supports writing almost every class to streams, and has it's own action-vm system. I'll have some samples and screens later (probably this week).
And I'm sorry for any typos because there's probably a lot...

_Some Basic Classes_

_Res_
A Res is a class for resources. All the visual classes in the engine like Sprites, use a Res in place of an Image.

_Some Res Types_ (But not all of them)
Res(id) - A null type. If your try to draw it, it will draw nothing.
Image(id, src, handleX=0, handleY=0) - Loads an image from src
ImageSection(id, srcid, x, y, width, height, handleX=-1, handleY=-1) - Grabs an image from a roImage with the id of srcid
AnimImage(id, srcid, framewidth, frameheight, framelimit=0, handleX=-1, handleY=-1) - Makes an animated image from a roImage with the id of srcid
ResGroup(id, resources, handleX=-1, handleY=-1) - Contains an array of res that can be drawn like a roAnimImage
ResSlot(id, resid, frame=0, action=Null) - This is a slot that draws another res. This is extremely useful for sprites. It draws the res from its frame and if you give it an action (Check Action class), it will render it everytime its drawn.
Text(id, fontid, text, handleX=-1, handleY=-1) - This draws text using another Res(fontid) as the font. The Font-Res is best to be a roResGroup because each res in a roResGroup can have different padding.
ExtendableImage(id, imagesandframes, handleX=-1, handleY=-1) - This is an extremely useful type of res if you have a game where you can equip items. This takes multiple images and draws them all from the point of the first image (also from the image's handle) and then captures them all (to the exact height and width) and that is the image it draws.
CustomImage(id, palette, width, height, pxls, handleX=-1, handleY=-1) - This is a custom image
TintedImage(id, srcid, tent, handleX=-1, handleY=-1) - This draws the Res of src id but tinted
TransformedImage(id, srcid, angle=0.0, scalex=1.0, scaley=1.0, handleX=-1, handleY=-1) - This draws a transformed Res(srcid)
TileImage(id, tiles, handleX=-1, handleY=-1) - This makes an image based on the tiles. The tiles argument is a list of int lists in this format [srcid, frame]
ResCollage(id, res, handleX=-1, handleY=-1) - This draws a bunch of res at once. The res argument is a list of float lists in this format [srcid, frame, x, y]
ResPackage(id, res) - The only purpose of this type is to hold a bunch of resources. Useful for if you want to delete a bunch of res at once or save a bunch of res in one file.
Sound(id, src) - A sound...

_Some Res Methods_ (But not all of them)
ChangeFrame(frame) - If the res uses a frame (Such as roResSlot) this changes the frame
ChangeFrame(childnumber, frame) - This is the same as above but for Res like roTileImage and roResCollage
Draw(x, y, frame=0) - This draws a res
Draw(x, y, frame=0, angle=0) - This draws a res
HandleX() - Returns the x handle of the Res
HandleY() - Returns the y handle of the Res
Height() - Returns the height of the Res
Play() - This plays the sound of a res
Save(dir="") - This saves the Res to a file with it's id in the res directory (default "data/resources")
Set(src="") - This sets a Res. The Res will not draw until this is called. This can be done in realtime because once it's set it won't keep setting itself.

_Some Res Functions_ (But not all of them)
Get(id, src="") - This gets a loaded res with that id. If their is no res with that id it will check the resource directory if a saved res with that id exists.
Load(id, src="") - This loads a res from a Res File (default "data/resources/id.res")
Read(stream) - This reads a res from a stream

_Sprite_
_Some Basic Sprite Types_(But not all of them)
Sprite(id) - This is a null class. Makes a sprite that does nothing.
Box(id, x, y, layer, width, height, passtype = 1, parent=null, pre=null) - This makes an invisible (but physical) sprite.
Primitive(id, res, x, y, layer, passtype = 1, parent=null, pre=null) - This makes a primitive sprite.
ActiveSprite(id, res, x, y, layer, brain, touch = None, passtype = 1, parent = null, pre = null) - This makes an active sprite.

_Some Sprite Methods_(But not all of them)
Draw(children=False) - This draws a Sprite. (Recommended to just allow a Sprite_Group do this.)
Move(x, y) - This moves a Sprite
Position(x, y, global = False) - This positions a Sprite
Save(dir="") - This saves a Sprite to a file. Default to "data/sprites/id.spr"
Set(group, dir="") - This sets a Sprite. This must be called for the Sprite to work. (Recommended to just allow a SpriteGroup do this.)
Update() - This updates a Sprite. (Recommended to just allow a Sprite_Group do this.)
Write(stream) - This writes a Sprite to a stream

_Some Sprite Functions_(But not all of them)
Get(id, src="") - This gets a Sprite. If the Sprite isn't loaded it will attempt to load one.
Load(id, src="") - This loads a Sprite from fille.
Read(stream) - This reads a Sprite from a stream.

_SpriteGroup_
A SpriteGroup is a group of sprites (duh).
Only sprites in the same group will detect collisions with each other.
Collisions can be turned off in case you want to use a physics engine or something like that.
SpriteGroup(id, sprites = [], collisions = True) - The calls a new sprite group.

_Some SpriteGroup Methods_(But not all of them)
Add(sprite) - Adds a sprite.
Draw() - This draws all the Sprites in the SpriteGroup.
Set(dir="") - This sets all the sprites in the SpriteGroup.
Update() - This updates all the sprites in the SpriteGroup.

_Action Classes_
There are 3 main classes to use with the Action system:
Parse - Returns Values
Cond - Returns Bools
Act - Performs Actions

_Some Parse Types_ (But not all of them)
If you just want to use normal values(Strings, Ints, Floats, Bools) within parses, conds, or acts then you will need to make NormalParses (Can be done simply with the function N(value))
Parse() - A null class. Returns 0.
ParseList(parses) - This returns a sum of all the parses.
NormalParse(value) - This just returns whatever value it holds. (You can also call N(value) to build a NormalParse)
GetValue(valuenum) - This returns a global value.
GetProp(prop) - This returns a system property
CondValue(cond) - This returns "cond"'s bool statement as a parse

_Some Res Parses:_ (But not all of them)
All Parses can be called with a Res, but these are Res specific:
GetProp(prop) - This returns a res property

_Some Sprite Parses:_ (But not all of them)
All Parses can be called with a Res, but these are Res specific:
GetProp(prop) - This returns a Sprite property
GetValue(valuenum) - This returns a value from the Sprite's local value list

_Parse Methods:_
tobool() - Returns the parse as a bool
tofloat() - Returns the parse as a float
toint() - Returns the parse as an int
tostring() - Returns the parse as a string
Write(stream) - Writes the parse to a stream

_Parse Functions:_
Read(stream) - Reads a parse from a stream

_Some Cond Types_ (But not all of them)
Cond() - A null class. Returns True.
CondList(conds) - If every cond in the list is True this will return true, otherwise it returns false.
EqualTo(values, valuetype=Null) - If all "values"(Parses) return the same value this returns True. The default value type for the Parses is String.
UnEqualTo(values, valuetype=Null) - If any "values"(Parses) return a different value this returns True. The default value type for the Parses is String.
GreaterThan(value1, value2, valuetype=Null) - Returns if value1 is greater than value2. The default value type for the Parses is String.
GreaterThanOrEqualTo(value1, value2, valuetype=Null) - Returns if value1 is greater than or equal to value2. The default value type for the Parses is String.
LesserThan(value1, value2, valuetype=Null) - Returns if value1 is lesser than value2. The default value type for the Parses is String.
LesserThanOrEqualTo(value1, value2, valuetype=Null) - Returns if value1 is lesser than or equal to value2. The default value type for the Parses is String.

_Cond Methods:_
Render() - Returns either True or False
Write(stream) - Writes a cond to a stream

_Cond Functions:_
Read(stream) - This reads a cond from a stream

_Some Act Types_ (But not all of them)
Act() - A null class. Performs nothing.
ActList(actions) - Performs an entire list of actions at once.
Action(actions, cur = 0) - Same as ActList but performs one action at a time everytime it's called.
Continual(actions, perishes=False) - Same as Action but once called, it continues by itself until finished. If "perishes" is set to True, it stops and cant be called anymore.
Conditional(cond, action) - Performs an action if the "cond" returns True
PerformActOnRes(resid, action) - A Res with the id "resid" will perform the act "action".
PerformActOnAllRes(action) - Performs "action" on all Res
PerformActOnSprite(spriteid, action) - A Sprite with the id "spriteid" will perform the act "action".
PerformActOnAllSprites(action) - Performs "action" on all Sprites
PerformActOnSpriteGroup(action) - Performs "action" on all Sprites in a Sprite_Group
Script(id, act) - An Act class just for the conveniencey of saving an Act to file and tagging an Act with an id
ActSlot(scriptid, cur=0)[/b] - Gets a roScript and runs it locally
SetValue(valuenumber, newvalue) - Changes a value in the GlobalValues

_Some Sprite Act Types_ (But not all of them)
(All actions can be called with a Sprite, (such as ActList), but these are specific.)
AllChildren(act) - This calls an act with all the children of a Sprite
Touching(act) - This calls an act with all the touching Sprites of a Sprite
Delete() - This deletes the sprite
Clone(newid, x, y) - This clones a Sprite (and it's children) to "x" and "y" with the id "newid"
Move(x, y) - This moves a Sprite
PerformActOnIcon(act) - This calls an act on the Sprite's local Res
Position(x, y, global=Null) - This positions a Sprite. Global if False by default.
SetValue(valuenumber, newvalue) - Changes a value in the Sprite's local Value List

_Some Sprite Act Types_ (But not all of them)
AllChildren(act) - This calls an act with all the children of a Sprite
AllTouching(act) - This calls an act with all the touching Sprites of a Sprite
Delete() - This deletes the sprite
Clone(newid, x, y) - This clones a Sprite (and it's children) to "x" and "y" with the id "newid"
Move(x, y) - This moves a Sprite
PerformActOnIcon(act) - This calls an act on the Sprite's local Res
Position(x, y, global=Null) - This positions a Sprite. Global if False by default.
SetValue(valuenumber, newvalue) - Changes a value in the Sprite's local Value List

_Some Act Methods:_ (But not all of them)
Render(cur=-1) - Performs an Act.
Render(res, cur=-1) - Performs an Act with "res".
Render(sprite, cur=-1) - Performs an Act with "sprite".
Save(dir="") - (Only with roScript) Saves a roScript to a directory. Default = "data/scripts/id.act"
Save(id, dir="") - This makes a roScript from the Act and saves it.
Write(stream) - This writes the Act to a stream.

_Some Act Functions:_ (But not all of them)
Get(id, dir="") - This find a roScript with "id" and returns it. If it's not loaded it will attempt to load it from a file.
Load(id, dir="") - This loads a roScript from file.
Read(stream) - This reads an Act from file.

_Other Stuff_
Like I said, the Kros Engine has A LOT more to it. Like canvases and other stuff like that. I'm fixing a bunch of the messy stuff before release.
Expansions that I'm working on:

Kros Gui - This works with this engine and is coming along great!

Kros3D - This implements minib3d and is coming along awesome

I'll have some samples and screenshots up later, probably this week. I hope some people find this engine interesting. It works absolutely great!

-CageInfamous


ordigdug(Posted 2013) [#2]
Looking forward to seeing samples and screenshots. Thanks for sharing.


Samah(Posted 2013) [#3]
Another engine?


Belimoth(Posted 2013) [#4]
Looks interesting! Are you planning to release it open-source?


Neuro(Posted 2013) [#5]
The more, the merrier.


Goodlookinguy(Posted 2013) [#6]
Another engine?


It shouldn't be that surprising. I think a number of people are probably using their own engines or at least their own library of code, including me.


MikeHart(Posted 2013) [#7]
Goodlookinguy, keep doing it and thanks for providing another solution. I find it great that Monkey users have a huge variety to choose from.


cageInfamous(Posted 2013) [#8]
Yeah I'll be releasing it free, I'm working on an editor program for it to sell. I'll have more up this week when my schedule opens a bit. Thanks for the positive feedback xD


Amon(Posted 2013) [#9]
I don't see the MakeMeAppStoreMillions() function!

Because of that this = fail!

Joking, of course! Good to see this and like others have said the more the merrier; more choices for all!

:)