[QUOTE=Maurice;35032580]Really? I thought it wasn't too bad.
I mean, you didn't expect the complexity of a Tetris clone, right?[/QUOTE]
But everything is a global :saddowns:
[QUOTE=Map in a box;35035035]But everything is a global :saddowns:[/QUOTE]
Holy sh*t !
Hey not everything.
Just almost.
Got tired of seeing this all over:
[lua]
coinsound = love.audio.newSource("sounds/coin.ogg", "static");coinsound:setVolume(0);coinsound:play();coinsound:stop();coinsound:setVolume(1)
[/lua]
So I made this class:
[lua]
function string.Left(str, num)
return string.sub(str, 1, num)
end
function string.Right(str, num)
return string.sub(str, -num)
end
audio = class:new()
local Sequences = {}
Sequences['vol'] = function( obj, arg ) obj:setVolume( tonumber(arg or 0) ); end -- setVolume
Sequences['v'] = function( obj, arg ) obj:setVolume(0); end -- setVolume(0)
Sequences['p'] = function( obj ) obj:play(); end -- play
Sequences['s'] = function( obj ) obj:stop(); end -- stop
Sequences['l'] = function( obj ) obj:setLooping(true); end -- loop
local function translateSeq( seq, obj )
if (not seq) or (not obj) then return false; end
local args = seq:split('/')
for k, v in pairs( args ) do
if v:find('v:') then
local num = string.Right( v, string.len(v) - 2 )
Sequences['vol']( obj, num )
end
if Sequences[ v ] then
Sequences[v]( obj )
end
end
end
function audio:new( File, Type, Seq ) -- File, Type, Sequence
local Obj = love.audio.newSource( File, Type )
translateSeq( Seq, Obj )
return Obj
end
[/lua]
Usage:
[lua]
--"v:0/p/s/v:1" translates to o:setVolume(0);o:play();o:stop();o:setVolume(1)
coinsound = audio:new("sounds/coin.ogg", "static", "v:0/p/s/v:1")
[/lua]
Currently in knife fight with git, attempting to update to 1.3
[editline]7th March 2012[/editline]
Okay I think a manual merge would be much easier at this point
[editline]8th March 2012[/editline]
Okay, I used WinMerge and updated my "Mari0 Modding System Mod" to 1.3.
I'd just like to say that jesus dick it's difficult to get new things into this without drastically changing it
Maurice, in my opinion, you need to work on the dynamicness of your code.
Maybe I should read a programming book/tutorial for once to learn some common practice.
[QUOTE=Maurice;35054287]Maybe I should read a programming book/tutorial for once to learn some common practice.[/QUOTE]
Could be worse, you could have spent most of your time making object factory pattern instance class variable abstraction layers and have nothing to show for it. Churn out an amazing game first, then clean it up :)
[QUOTE=Maurice;35054287]Maybe I should read a programming book/tutorial for once to learn some common practice.[/QUOTE]
Well, take mario.lua as an example.
Look at :floorcollide (or any of the other "collide"s). You have an almost null-level if-elseif chain, in which you check what type of entity mario is colliding with. Instead of massive hard-coded a == "x" or a == "y" or a == "z", you could have a property of b that you check.
I've never really read books on any of this. When I find myself hard coding things, I just ask myself "Isn't there an easier way of doing this?"
[editline]8th March 2012[/editline]
Oh yeah I got my modding system mod to load entities correctly, staying compatible even after installing/uninstalling other mods. This is important because mods get an id/index thing when they are created, which is used to keep track of it and it's name and the map format. When you add something new that would get loaded before, it would normally upset the whole system, but I made it move stuff around until it works, and keep entities loading at whatever id/index thing they were when the map was saved.
[editline]8th March 2012[/editline]
I think I'll release my modding system on the forums. I wish I could say that adding enemies works but 1.3 kinda broke my test koopa so whatever
[QUOTE=Maurice;35054287]Maybe I should read a programming book/tutorial for once to learn some common practice.[/QUOTE]
Personally I just think "How can I make it so that I never have to write this bit of code again?" and organize my code that way. Sometimes something of a design pattern will form as I'm writing the code, but I rarely approach a problem by trying to fit a design pattern around it. It's very easy to get caught up in design patterns and overengineer your game while never really getting anything done.
I'll usually "design" bits of a game to the point where I won't have to copy/paste really large blocks of code to get things to work then start hacking in features. After that it's usually waves of hacking things in and then cleaning up the code.
Learn about design patterns and organization, but don't be overzealous about using them as your actual productivity will tank. You're really good at making working prototypes really quickly and that's a good thing. Don't change the way you prototype, just learn to clean up your code afterwards.
Maurice, normally such a coding style would be shunned upon.
The overuse of globals and the needless repetition of logic is... pointless; hence why "Software Engineering" even exists.
But your code doesn't count...
The end result of your work is so incredibly awesome, that we are perplexed how at well it turned out considering the painful coding methods.
You are so determined - so industrious - that you can create magic from dirt.... a palace from sticks... [b]Mario wih Portals from ugly Lua on a barely documented platform![/b]
We're jealous! We spend so much of our time refactoring our code to make it "easier", while you're fiddling with sonic rainbooms and hats.
If you were to learn the "proper" ways of doing things (which is a cop-opt: there is no 'correct' way... As long as it works), you would be [b][i]dangerous[/i][/b].
You would pump out epicness so fast that they're be a "WIMWO" thread that'd outshine WAYWO.
You are a programming god!
[QUOTE=Deco Da Man;35061296]If you were to learn the "proper" ways of doing things (which is a cop-opt: there is no 'correct' way... As long as it works), you would be [b][i]dangerous[/i][/b].
You would pump out epicness so fast that they're be a "WIMWO" thread that'd outshine WAYWO.[/QUOTE]
I feel like it's more likely to work in the exact opposite way, where all that productivity that usually goes into adding features is instead spent doing things "properly"
[QUOTE=robmaister12;35061352]I feel like it's more likely to work in the exact opposite way, where all that productivity that usually goes into adding features is instead spent doing things "properly"[/QUOTE]
What 'good' coders have in 'proper'-ness, they lack in determination and industrious.. ness
Maurice has an iron will. He pumps out code at an unnatural rate.. this may be due to his direct coding nature (and hence no time wasting on refactoring), but I believe that it's due to his personality and rive.
I have no drive and never get anything done, even when I pump it out with little thought to doing it 'properly'.
[editline]![/editline]
Also, the more structure to the design, the more likely that anti-patterns may form.
The architecture of Maurice's code lacks sophisticated architecture, and hence there aren't many patterns at all. His code simply operates on the low-level APIs for whatever he needs to do... it "oozes" over it.
Conclusion: He is a fungus. Q.E.D.
[QUOTE=Deco Da Man;35061469]What 'good' coders have in 'proper'-ness, they lack in determination and industrious.. ness
Maurice has an iron will. He pumps out code at an unnatural rate.. this may be due to his direct coding nature (and hence no time wasting on refactoring), but I believe that it's due to his personality and rive.
I have no drive and never get anything done, even when I pump it out with little thought to doing it 'properly'.[/QUOTE]
That's actually quite true. I think it's mostly personality, but even the best can fall into the trap of endless refactoring. I've fallen into it a bit recently while trying to design a rendering system that can fallback on older version of OpenGL when necessary for a game I'm working on. I'm almost done with it though. Before that my friends were stuck on a writing a physics engine for a good 3-4 months until I saw that we weren't getting anywhere and told them to pull the physics code out and work on it on their own time, then dropped in Farseer and it worked much better. So maybe I have a bit of a jaded view on the subject.
I like the way Garry talks about this stuff. If you can get a finished, polished product out into the world then it doesn't matter how you got it done. You might be making things difficult for yourself later on, re: patches, modifications, etc. But nothing can change the fact that you finished what you set out to do, which is far more important than being a 'good' programmer.
I'd still like to learn the "proper" way, though. Honestly, Mari0 is like the most structured of all of my projects.
Thanks for all the kind words!
The proper way is the one you are most comfortable with...
...unless you work with someone else or plan to share the code :P
[QUOTE=Nigey Nige;35062868]I like the way Garry talks about this stuff. If you can get a finished, polished product out into the world then it doesn't matter how you got it done. You might be making things difficult for yourself later on, re: patches, modifications, etc. But nothing can change the fact that you finished what you set out to do, which is far more important than being a 'good' programmer.[/QUOTE]
Of course, if you are working in a commercial environment such as a big-name game development company, you often cannot afford to write 'bad' code.
So I released my mod loader on the forums last night
Someone updated it to 1.4 for me without even being asked to :3
-snip-
Need to look around more.
Maurice, here's something which might help out a bit.
mario.lua, in the left and right collide functions:
[lua]--You can change
elseif a == "box" then
--to
elseif b.pushable then
--and now anything with b.pushable == true can be pushed.[/lua]
Definitely made making personality cores easier
[editline]10th March 2012[/editline]
Also, if you use this checkrect:
[lua]function checkrect(x, y, width, height, list, statics)
local out = {}
local inobj
if type(list) == "table" and list[1] == "exclude" then
inobj = list[2]
list = "all"
end
for i, v in pairs(objects) do
local contains = false
if list and list ~= "all" and type(list) == "table" then
for j = 1, #list do
if list[j] == i then
contains = true
end
end
end
if type(list) == "function" then
contains = true
end
if list == "all" or contains then
for j, w in pairs(v) do
if statics or w.static ~= true or list ~= "all" then
local skip = false
if inobj then
if w.x == inobj.x and w.y == inobj.y then
skip = true
end
--masktable
if (inobj.mask ~= nil and inobj.mask[w.category] == true) or (w.mask ~= nil and w.mask[inobj.category] == true) then
skip = true
end
end
if not skip then
if w.active then
if aabb(x, y, width, height, w.x, w.y, w.width, w.height) and (type(list) ~= "function" and true or (list(w) == true)) then
table.insert(out, i)
table.insert(out, j)
end
end
end
end
end
end
end
return out
end[/lua]
You can pass a function and check for properties or other things instead of saying exactly what should be checked.
[editline]10th March 2012[/editline]
[img]http://dl.dropbox.com/u/45554193/images/mari0%20and%20personality%20cores.png[/img]
If you want to try my modloader and the mods I've made for it, grab it [url=http://forum.stabyourself.net/viewtopic.php?f=13&t=782]here[/url]
[media]http://www.youtube.com/watch?v=O0qYF7p3z8I&feature=g-all-u&context=G2f4e6afFAAAAAAAABAA[/media]
Just thought I should leave this here.
I will just assume these people are youtube famous or something.
Yay.
Yeah they're pretty well-known in the gaming community.
[url]http://roosterteeth.com[/url]
They've made Red vs Blue so you could expect a massive increase in your following.
you've made it on Spiegel Online ([URL="http://www.spiegel.de/netzwelt/games/0,1518,783667,00.html"]again[/URL]):
[url]http://www.spiegel.de/netzwelt/games/0,1518,825825-2,00.html[/url]
:eng101: congrats Maurice!
Sorry, you need to Log In to post a reply to this thread.