GameUtils- Now with Collision Detection!
nitrogenfingers 10 Feb 2013
FuuuAInfiniteLoop(F.A.I.L) 10 Feb 2013
and using certain pixels from the images for each sprite?
nitrogenfingers 10 Feb 2013
I don't think I'll ever implement this for collision detection- if you want to do this I recommend using layering to create a "bounding object", which is just the shape you want your shape to collide with (this implementation is very trivial, just switch frames before collision checks and switch back before draw calls). However, plans to draw only certain pixels within a rectangular area of the image is a planned feature of the next version of game utils
Skullblade 10 Feb 2013
nitrogenfingers 12 Feb 2013
Updated today with a few changes:
- Fixed a bug with animations appearing off-centre when positions are initialized in the constructer
- Removed some debug scripts when loading sprites from file
- Allowed animations to be updated without a timer ID, this being a "forced update". Passing a nil timer ID will allow this; animating using timers should still pass through whatver ID the timer used.
- Added a "moveTo" method for sprites and animations. Access to X and Y is possible directly but this is unsafe as this refers the transformed coordinates according to the sprite's bounding box, not to relative screen space. You can still increment the X and Y values safetly enough for relative motion, but for absolute positioning on the screen it's unsafe, so moveTo is necessary. I've workshopped a few different ways of solving this issue and ironically it's the first time I've yet to come across where access restrictions feel completely necessary, but for the moment this will remain. For consistency I'd recommend using moveTo for relative motion as well.
I'm also planning on peppering this post with screenshots of games I've made using gameutils- I've done one or two little games and am working on at least two new demonstrations for how to use the API (particularly animation features and loading), and am working on at least one "tech demo" game. So here's the first, hopefully of many more to come!
- Fixed a bug with animations appearing off-centre when positions are initialized in the constructer
- Removed some debug scripts when loading sprites from file
- Allowed animations to be updated without a timer ID, this being a "forced update". Passing a nil timer ID will allow this; animating using timers should still pass through whatver ID the timer used.
- Added a "moveTo" method for sprites and animations. Access to X and Y is possible directly but this is unsafe as this refers the transformed coordinates according to the sprite's bounding box, not to relative screen space. You can still increment the X and Y values safetly enough for relative motion, but for absolute positioning on the screen it's unsafe, so moveTo is necessary. I've workshopped a few different ways of solving this issue and ironically it's the first time I've yet to come across where access restrictions feel completely necessary, but for the moment this will remain. For consistency I'd recommend using moveTo for relative motion as well.
I'm also planning on peppering this post with screenshots of games I've made using gameutils- I've done one or two little games and am working on at least two new demonstrations for how to use the API (particularly animation features and loading), and am working on at least one "tech demo" game. So here's the first, hopefully of many more to come!
bjornir90 17 Feb 2013
You said that we can only draw a part of a sprite for scrolling features, but how do I do that?
MudkipTheEpic 05 Mar 2013
Is there any way to scroll in this or do drawSprite(image, -number, 1) to kinda scroll? Or are you adding that later.
darkroom 07 Mar 2013
Hey guys I was making a game with gameUtils and I was like you know what this needs.... a better buffer drawing function. So I wrote one. Basically what it does is checks if the pixels are different and if they are it changes them. This eliminates 95% of flicker.
Here you go
Here you go
function drawBuffer(terminal,backgroundColor) if not terminal then terminal = term end backgroundColor = backgroundColor or colors.lightBlue if not backbuffer then error("Back buffer not yet initialized!") end if not terminal.setCursorPos or not terminal.setBackgroundColour or not terminal.write then error("Parameter cannot be used to initialize the backbuffer.") end if not terminal.isColour() then error("Parameter does not represent an advanced computer.") end --I used these lines alot so I put it in a function local function modWrite(x,y,color,text) local color = color or colors.black local text = text or " " terminal.setCursorPos(x,y) terminal.setBackgroundColour(color) terminal.write(text) end if backbufferOld then for y=1,math.min(#backbuffer,th) do for x=1,tw do if backbuffer[y][x] == backbufferOld[y][x] then if backbuffer[y][x] then modWrite(x,y,backbuffer[y][x]) else modWrite(x,y,backgroundColor) end else if backbuffer[y][x] then modWrite(x,y,backbuffer[y][x]) else modWrite(x,y,backgroundColor) end end end end else for y=1,math.min(#backbuffer, th) do for x=1,tw do if backbuffer[y][x] then modWrite(x,y,backbuffer[y][x]) end end end end --Performs a "deep copy" of the table so we dont get pointer problems backbufferOld = textutils.unserialize(textutils.serialize(backbuffer)) end
CastleMan2000 09 Mar 2013
darkroom, on 07 March 2013 - 12:38 PM, said:
Hey guys I was making a game with gameUtils and I was like you know what this needs.... a better buffer drawing function. So I wrote one. Basically what it does is checks if the pixels are different and if they are it changes them. This eliminates 95% of flicker.
Here you go
-snippy
Here you go
-snippy
makerimages 21 Jul 2013
How does one use nextA?
This is my code, which doesnt work
This is my code, which doesnt work
--Developed by Makerimages os.loadAPI("/apis/gameutils");--Load the animation api local topBar=gameutils.loadSprite("/graphics/TopBar.nfp",1,1);--top bar local w, h=term.getSize(); local loadBar=gameutils.loadAnimation("/graphics/LoadingBar.nfa",math.ceil(w/2-3),math.ceil(h/2));--loading bar loadBar.currentFrame=1; gameutils.initializeBuffer(); gameutils.writeToBuffer(topBar); gameutils.writeToBuffer(loadBar); gameutils.drawBuffer(); while true do loadBar.nextA(loadBar); endloadBar has 11 frames
TorakTu 05 Aug 2013
I just wanted to say TY so very much for this API. It will be something I can examin on how you did things. Kudos !!