urielsalis, on 09 February 2013 - 06:13 PM, said:
2
GameUtils- Now with Collision Detection!
Started by nitrogenfingers, Dec 11 2012 05:58 AM
34 replies to this topic
#21
Posted 10 February 2013 - 12:44 AM
and other thing that can be added is that we can use nfa files to use each frme as a sprite for diferent objects so less files
#22
Posted 10 February 2013 - 05:05 AM
and using certain pixels from the images for each sprite?
#23
Posted 10 February 2013 - 11:48 AM
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
#24
Posted 10 February 2013 - 12:30 PM
I will try
#26
Posted 12 February 2013 - 04:36 PM
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!
#27
Posted 17 February 2013 - 08:34 PM
You said that we can only draw a part of a sprite for scrolling features, but how do I do that?
#28
Posted 18 February 2013 - 11:43 AM
Not yet- this feature is upcoming.
#29
Posted 05 March 2013 - 11:10 AM
Is there any way to scroll in this or do drawSprite(image, -number, 1) to kinda scroll? Or are you adding that later.
#30
Posted 07 March 2013 - 12:38 PM
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
#31
Posted 09 March 2013 - 05:02 AM
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
#32
Posted 21 July 2013 - 11:43 AM
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
#33
Posted 05 August 2013 - 12:26 PM
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 !!
#34
Posted 09 August 2013 - 08:35 AM
sry wrong topic
#35
Posted 14 August 2013 - 04:14 AM
Any progress on the support for nft files?
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users