This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Xenthera's profile picture

Cc2D V0.02 - Löve2D Style Engine For Computercraft! (Baby Steps)

Started by Xenthera, 14 August 2013 - 11:21 PM
Xenthera #1
Posted 15 August 2013 - 01:21 AM
Do you use Löve? If so, you'll 'löve' this… heh… get it? No? ok.

INSTALL
To download, paste this into your computer

pastebin get M6TPyV60 install


GETTING STARTED (READ ME DANG YOU!):
(real tutorial coming soon)
SpoilerStep 1: Once you have downloaded the install file, run it. It will install the necessary components, and delete itself.

Step 2: To start a brand new program, run the file 'cc2d' (no quotes)

That will bring you to a screen where you enter your new program name.

Once done, you will be presented with your 3 basic functions of CC2D





function load() - Called once when the program is ran, where you declare variables and such



function update() - Callback function used to update the state of the game every frame.



function draw() - Callback function used to draw on the screen every frame.


"X, I've tried to run my program, but it's not doing anything! HALP MEH D:!!111!Asdasjdnk"
RUNNING YOUR PROGRAM:
SpoilerStep 3: To run your CC2D program, type 'cc2d <program name>'

So far, there is only 1 API called graphics, it's referenced automatically so you don't have to import it every time you write a new program

Graphics methods

graphics.setColor(color) - [b]sets draw color[/b]

graphics.print(text,x,y) - [b]prints text to screen at x,y -(WIP)[/b]

graphics.circle(x,y,radius) - [b]draws circle at x,y with given radius[/b]

graphics.rectangle(x,y,width,height) - [b]draws rectangle at x,y (origin top left) with given width,height[/b]

graphics.line(startX,startY,endX,endY) - [b]draws line from two given points (same as paintutils.drawLine, added for consitency)[/b]

graphics.pixel(x,y) - [b]draws a pixel at x,y[/b]

CC2D core methods

load() --REQUIRED!
update() --REQUIRED!
draw() --REQUIRED!

keyPressed(key) --Not required, called automatically when a key is pressed (if the method exists)

mouseClicked(button, x, y) --Not required, called automatically when the mouse is clicked (if the method exists)




Some 'gotchas' to be aware of:

- Much like Love2d, graphics API does not work outside of the draw method.
- Due to limits of CC, CC2D runs at 20 fps
​- Not recommended for server usage
(probably more soon)


Example!



Once you've installed CC2d, you can also download this sample program I wrote real quick. Make a nice size monitor like so.

Download this

pastebin get usuk7uwr demo

Then run

monitor right cc2d demo

CC2D is making baby steps. Suggestions are welcome!

Post games or demos you make, and I may add them to this post

Release Changes:
Spoiler

[i]V0.02 (Baby Steps)[/i]
+ Added keyboard and mouse support
* Bug Fixes
[i]V0.01 (Early Stages)[/i]
* Initial Release
+ Added Graphics API
+ Added Everything else..
Dave-ee Jones #2
Posted 15 August 2013 - 01:45 AM
Neat! I like the circle generator, it looks good :D/>


Also, where do people get these CC Texture packs!?
I want one! :(/>
Xenthera #3
Posted 15 August 2013 - 01:58 AM
Thanks, and it's just a flavor of Faithful 32x32 for ftb
Dave-ee Jones #4
Posted 15 August 2013 - 04:52 AM
So you don't use Minecraft to use CC? You use FTB? That's probably why. I use Minecraft so I cannot find any working CC texture packs. :(/>

EDIT: Just looked up Faithful 32x32 and it shows that it does support CC :D/> Thanks.
Xenthera #5
Posted 15 August 2013 - 04:52 PM
I generally use FTB mostly because i'm too lazy to download an install the files. Especially with 1.6 being such a pain to do so with.
Zarty55 #6
Posted 25 September 2013 - 07:43 PM
Exactly what I was looking for! Oh, and yes, I love LÖVE2D haha :)/>

Going to try it out ;)/>

Edit: It seems there is a problem with the graphics API. It isn't being loaded right. I've tried the demo program to see if I was doing something wrong and it is giving a error as well.

Edit2: Allright, sorry. I see the problem, the API is being loaded after the engine runs the load() function. I don't know if this is supposed to happen though.
joshmanisdabomb #7
Posted 26 September 2013 - 05:32 AM
Why does everyone have the same idea as me. :(/>
Circle generator looks nifty.
Xenthera #8
Posted 26 September 2013 - 02:54 PM
Is screen-flicker not present? I mean if you're gonna redraw every single frame unless you got a slow framerate in CC wouldn't it cause flickering?
How much FPS (when running non-intensive drawing operations) is it?
Also, as a feature request in the future, I want to be able to package a game and run it the same way I can do with .love files on my computer! (That'd be aweshum)


On single player there is no flickering. On multiplayer however, it all depends on the connection.
The fps is locked at 20 frames per second. On single player I can render 3d cubes and other simple shapes and it doesn't have a problem.
For the feature request, i'm working on it right now actually.


Edit: New Update - V0.02 Codename "Baby Steps"
Xenthera #9
Posted 27 September 2013 - 02:57 PM

It doesn't natively support 3d, I programmed the 3d from scratch using this (cc2d). I feel it's too much of a pain with computercraft's pixel size to implement an api for 3d. Plus, it's CC2D, not CC3D :D/>

-Also I'll add the fps limiter as well.

About the other 'competitors' - I'm not trying to beat anyone. If theirs is better, then use it! ;)/> However, that doesn't mean i'm going to stop developing my.. (for consistency) 'engine'.
joshmanisdabomb #10
Posted 27 September 2013 - 06:09 PM
Good engine, but it looks like you got a few competitors so you might have to get quite a few more updates in!

About the other 'competitors' - I'm not trying to beat anyone. If theirs is better, then use it! ;)/> However, that doesn't mean i'm going to stop developing my.. (for consistency) 'engine'.

Ooooh, the jabs. :D/>
I'm just making my Löve2D thing for the heck of it. Not really bothered about which comes out on top either.
joshmanisdabomb #11
Posted 27 September 2013 - 08:27 PM
Good luck you two! :D/>

Don't forget about this guy. If he's still working on his version.

I've never really uploaded a program to this forum, let alone have "competition" as you guys call it. It's scary.