Jump to content




[API] CGE - Computercraft Game Engine [v1.2] - Colors!


38 replies to this topic

#1 billysback

  • Members
  • 569 posts

Posted 08 October 2012 - 09:29 PM

Posted Image
CGE is ComputerCraft Game Engine it is an API which can vastly reduce the amount of code needed to made a mini game (or other applications) and simplify the code needed. It does not do lots currently but I hope for it to grow, with hopefully the communities help. So for this reason I ask you to please reply to say either what you think of it, what your first impressions are, a suggestion for it or anything of that sort. Thank you.

Functions:
Spoiler

Heres a paste of CGE:

Heres a download:
Spoiler

Heres an example program paste:

Heres a tutorial (v1.1)
Spoiler

Updates:
Spoiler
(+ = new ; - = removed ; * = changed ; ^ = other)

Please reply like I said earlier :D/>

Thanks!

#2 wilcomega

  • Members
  • 466 posts
  • LocationHolland

Posted 09 October 2012 - 02:30 PM

no pics no clicks

#3 billysback

  • Members
  • 569 posts

Posted 09 October 2012 - 02:36 PM

pics of what? it's an API, the code is up there if you are worried about malicious code look at it...

#4 wilcomega

  • Members
  • 466 posts
  • LocationHolland

Posted 09 October 2012 - 07:31 PM

i mean like an example of what you can do with it. and make pics of that or something

#5 billysback

  • Members
  • 569 posts

Posted 09 October 2012 - 07:44 PM

you mean like the example program paste?
I'm creating a tutorial right now for creating a pacman game, I can attach a picture of the working pacman game once that is complete at the end, would that be enough?

#6 billysback

  • Members
  • 569 posts

Posted 10 October 2012 - 09:26 PM

UPDATE:
added a (hopefully) very in-depth tutorial for the newest version

- fixed A LOT of bugs :P/>
- added ability to animate sprites
- added ability to set and use sprite velocity for easier use of movement.

(look at updates for full list of function additions/changes)

#7 ChaddJackson12

  • Members
  • 264 posts

Posted 14 October 2012 - 03:07 AM

Seems interesting, I am not smart enough to make a game yet. But I think there could be quite a few cool games made with this.

#8 SeniorFight

  • Members
  • 7 posts
  • LocationMinecraft

Posted 14 October 2012 - 02:37 PM

Good idea :3
There is something i recommend:
Add dispGrav(sprite) to make a gravity for the sprite.
Add setGravBase(posX, posY) to make a base for gravity.
Add getSpriteCode() to get a string code of the sprite to share it by RedNet.
Add reverseSprite(sprite, side) to make a reversement of the sprite (like mirror)
That's all i recommend :)/>

Epic idea.
Not easy use... But gooood work with the sprites =D

#9 billysback

  • Members
  • 569 posts

Posted 14 October 2012 - 04:44 PM

I'll add getSpriteCode(), though getSprite() is just a table containing the sprite's code, if that makes sense...
I'll also add recieveSpriteCode() which just reverses it...


reverseSprite would be easy, however the gravity idea would be a bit more complicated;
would it work better as it's own function or integrated as an optional feature in the updateVelocity()?

Note:
I'm going to add color support; it would work in literrally exactly the same way but where the type is you would put the color of the pixel;
I'm debating whether to make it support Minecraft Color Tags or to make it run on its own (which would make it a hell of a lot harder for me and would be cause for a delay in an update; what do others think?)

Edit:
Coming in next update:
--Ability to get sprites and maps from files!
(Including animates sprites using multiple files)
--Ability to use color tags to create colored games (this and reading sprites from files means you could use a program such as CTR to create
--Colored sprites and use them in your game!
--reverseSprite()
--gravity

Edit #2:
The only thing I am waiting for now is permission to use marumaru's code, then I can update CGE with color support, gravity support, file reading support, code formatting support!

Edit #3:
A little note on the gravity:
Spoiler
Can anyone else think of a better way that this could work?

#10 Tiin57

    Java Lunatic

  • Members
  • 1,412 posts
  • LocationIndiana, United States

Posted 14 October 2012 - 06:59 PM

Great work on this.

#11 tommyroyall

  • Members
  • 136 posts

Posted 14 October 2012 - 07:15 PM

Btw, on the pac-man example, there's quite a few bugs. Copy the exact code from the end, then try to run it. I've found a couple already.

#12 billysback

  • Members
  • 569 posts

Posted 14 October 2012 - 07:30 PM

Updated the tutorial so it works, sorry :)/>
(the map and wall tables are messed up formatted wise whenever you copy them, don't really know why and it doesn't seem to be something I can fix)

#13 billysback

  • Members
  • 569 posts

Posted 15 October 2012 - 03:04 PM

Updated CGE:
look at "Updates" Spoiler!
(Main additions: Color support using MCT format and Gravity!)

NOTE:
I am currently creating a CGE script.
As CGE has a ridiculous amount of functions it won't call function and will instead run programs...

#14 faubiguy

  • Members
  • 213 posts

Posted 20 October 2012 - 04:40 PM

Great work. I'm using this for a Tetris game. I have two questions, is it possible to rotate sprites, or should I create a separate sprite for each frame of rotation? Also, does checkCollision return true if there is a collision between a space and a solid character or two spaces, or only between two characters? What about for colors?

#15 billysback

  • Members
  • 569 posts

Posted 21 October 2012 - 12:17 PM

checkCollision will return true if the sprite collides in any way with any of the sprites in the table.
Colors should work in the exact same way, except any color in your sprite will collide even if it is white (for example)

There isn't a rotate function, but if you look at this thread:
http://www.computerc...__fromsearch__1
(look at the last post)
You should be able to see how you could rotate it by using the flip function.

#16 faubiguy

  • Members
  • 213 posts

Posted 21 October 2012 - 01:29 PM

Thanks. One other thing, how can I make a sprite with color? Its probably pretty simple, but I can't find it in your list of functions or tutorial.

#17 billysback

  • Members
  • 569 posts

Posted 21 October 2012 - 03:48 PM

You use the normal functions in exactly the same way but just put MCT tags instead of characters.

#18 faubiguy

  • Members
  • 213 posts

Posted 22 October 2012 - 02:25 AM

constructSprite and createSprite apparently don't support color tags due to the way they work. How do I make colored sprites? (I'd prefer not to read from files as I'd like my game to be contained in one file. Hard-coding the sprites isn't an issue.)

EDIT: Also the getSpriteBounds function returns the lower-right bounds twice instead of top-left bounds and lower-right bounds

#19 billysback

  • Members
  • 569 posts

Posted 22 October 2012 - 03:14 PM

only constructSprite doesn't support colors because it gets each seperate character in each string in the table the sprite is created using, however because of how createSprite works (each character being in it's own string) it DOES support color support, so if you put color tags in the ttable and use colorDraw() then the game will detect that character as a color tag and draw it as a color.

I could add a constructColorSprite which would be the same as constructSprite but it gets each character by splitting the string at a space.
I will fix getSpriteBounds for the next update, if you want to fix it your self go to line 393 and copy in this code down to line 416
Spoiler


#20 faubiguy

  • Members
  • 213 posts

Posted 22 October 2012 - 03:51 PM

Ok, thanks. Sorry for assuming that createSprite wouldn't work.

Could you add a function for getting a list of all pixels in a sprite? Something like {{1, 1, "#"}, {2, 1, ">"}, {1, 2, "#"}, {2, 2, ">"}} for the sprite
#>
#>
I think that's similar to how sprite "objects" work, so it shouldn't be too hard to do.

Also is there any way to use magenta in sprites? MCT doesn't have a magenta tag.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users