• Gwilty's Programming Assignments #1
    355 replies, posted
[QUOTE=Osherzz;32897220]I think you're missing the whole point of expanding your knowledge[/QUOTE] I worked in C# a lot and I really want to get into game programming. Until the last few days I worked exclusively with XNA and I decided to switch to SFML because it gives the programmer much more freedom in handling certain parts of a game. I admit my first post wasn't very clear but before you guys get the wrong idea: Even though I'm experienced with C# quite a lot, it's still my goal to learn someting new / to extend my knowlege! (learning how to use SFML to its fullest). So please no more dumb ratings or the like.
I'm done! Whee. Never worked with LUA before so I'm pretty proud [media]http://www.youtube.com/watch?v=EZKD9EtWmjs[/media] Download if you want to [url]http://dl.dropbox.com/u/679615/TheMostExcitingGameEverMade.zip[/url]
Look at this kids fancy ball. [IMG]http://i869.photobucket.com/albums/ab255/Yournameisinvalid21/ball.png[/IMG]
So I ended up with this Typewriter Space Pong Breaker Extreme! [media]http://www.youtube.com/watch?v=bYaFDm6SXjM[/media] Shit's intense...
[media]http://www.youtube.com/watch?v=-2Aqn5cn9Zg[/media]
[QUOTE=mechanarchy;32898916][media]http://www.youtube.com/watch?v=-2Aqn5cn9Zg[/media][/QUOTE] [URL="http://steampowered.com/steamworks/title-submission.php"]You know what to do.[/URL]
[QUOTE=BlkDucky;32899028][URL="http://steampowered.com/steamworks/title-submission.php"]You know what to do.[/URL][/QUOTE] Applying now! [editline]a[/editline] [url=http://dl.dropbox.com/u/6929441/gwilty01.love]here's a link[/url] to the current build of this [del]monstrosity[/del]moostrosity, if anyone feels like playing it. source included, of course.
Well I have never done anything in lua before, but after reading up on some tutorials it was pretty easy to grasp. Decided to throw in physics for some [b]extreme fun[/b]. Download: [url]http://pixellegacy.com/extremebreakout.love[/url] [img]http://img846.imageshack.us/img846/1651/screenshot2011102121132.png[/img]
How do you draw more than one object? I'm using [lua]function love.draw() love.graphics.rectangle("line", rect.x, rect.y, rect.width, rect.height) end[/lua] for my paddle and trying to use this with some size adjustments for my ball [lua]function love.draw() love.graphics.circle ("line", 300, 300, 50, 10) end[/lua] but it only draws my ball, and not my paddle.
I made it [media]http://www.youtube.com/watch?v=wPh-C9kTdw8][/media] Very intense, the ball has no gravity tho.
[QUOTE=LordCrypto;32899705]How do you draw more than one object? I'm using [lua]function love.draw() love.graphics.rectangle("line", rect.x, rect.y, rect.width, rect.height) end[/lua] for my paddle and trying to use this with some size adjustments for my ball [lua]function love.draw() love.graphics.circle ("line", 300, 300, 50, 10) end[/lua] but it only draws my ball, and not my paddle.[/QUOTE] Put them both together. [lua] function love.draw() love.graphics.rectangle("line", rect.x, rect.y, rect.width, rect.height) love.graphics.circle ("line", 300, 300, 50, 10) end [/lua] love.draw draws everything at once, so it's where you should put all of your sprites to be drawn, like the ball and paddle, all of the text, etc. love.update is where you put all your logic, to make the ball move and such. love.load is where you put all the stuff that happens at the start - to load images, set up ball and paddle positions and such.
[IMG]http://i.imgur.com/SfObN.png[/IMG] Programmer art [editline]21st October 2011[/editline] [vid]http://filesmelt.com/downloader/breakout.ogv[/vid] [editline]21st October 2011[/editline] Ignore the broken time, conversion fail
I think I'll try this out. I've never done Lua before, but I've been interested in it and this seems like a good way to start.
I've been wanting to use LÖVE for a while so I just thought I might as well try it out now. [img]http://www.peniscorp.com/stuff/Breakout-2011-10-22_11.08.24.png[/img]
I'm getting some seriously weird things going on, i'm not even sure what the problem is. My numbers are changing from compile to compile. One compile it works right, one compile it does completely the wrong thing with no changes made at all. Take a look at the code below, this makes sense that the ball would move to the right, yes? Well it might do that, and then the second time you run it, it may move in the other direction, or the starting position of the ball would be off the screen, etc. I have no clue what's going on, but it's irritating. [lua]g = love.graphics k = love.keyboard t = love.timer p = love.physics function love.load() g.setMode(1280,720,false,true,4) g.setBackgroundColor(32,32,32) ball_x = 640 ball_y = 100 ball_image = g.newImage("ball.png") end function love.update( dt ) ball_x = ball_x + (100*dt) end function love.draw() g.draw(ball_image, ball_x, ball_y) end[/lua] I mean is anything even wrong with this? Even something simple like this is totally unpredictable on my machine for some reason.
[QUOTE=Pastor Eugene;32903209]I'm getting some seriously weird things going on, i'm not even sure what the problem is. My numbers are changing from compile to compile. One compile it works right, one compile it does completely the wrong thing with no changes made at all. Take a look at the code below, this makes sense that the ball would move to the right, yes? Well it might do that, and then the second time you run it, it may move in the other direction, or the starting position of the ball would be off the screen, etc. I have no clue what's going on, but it's irritating. [lua]g = love.graphics k = love.keyboard t = love.timer p = love.physics function love.load() g.setMode(1280,720,false,true,4) g.setBackgroundColor(32,32,32) ball_x = 640 ball_y = 100 ball_image = g.newImage("ball.png") end function love.update( dt ) ball_x = ball_x + (100*dt) end function love.draw() g.draw(ball_image, ball_x, ball_y) end[/lua] I mean is anything even wrong with this? Even something simple like this is totally unpredictable on my machine for some reason.[/QUOTE] If you're gonna do that trick with shortening the names for a performance gain, at least make the variables local so it doesn't have to look through _G. What do you mean by random numbers though? Your code seems perfectly fine as far as I can tell.
well, i've just tried it on my laptop, and it runs fine. However, on my main PC it's like the numbers aren't even there, and it's just choosing a random one to fill it in with. ball_x = 640 doesn't set ball_x to 640, sometimes it'll set it to like 80,434,562 sometimes it'll set it to -40, sometimes it'll set it to 5356, etc. Something's funky with my computer. It took me 2 hours to even notice that the code wasn't what was messing up, but my computer. I don't know how to fix it either.
[QUOTE=Pastor Eugene;32903209]My numbers are changing from compile to compile.[/QUOTE] You don't actually 'compile' lua code (in this case), it's interpreted. If you mean 'compile' as in shove all the stuff into a .zip file, rename it to .love and then run it, you can avoid this whole hassle by just running "love c:/path/to/game/folder/" in a command prompt. I'm doing a similar thing for mine, and it makes it much easier to just make a change, save, and then run with the new alterations without having to do the whole zip-packaging thing.
Actually, i'm just having Scite just do all the command promt stuff for me in the lua.properties file, but yeah I know, I just couldn't think of a better word to suit what I was trying to get across.
This is what I have so far: [img]http://puu.sh/7nHO[/img] [del]• Some kind of paddle at the bottom[/del] [del]• Control the paddle with the mouse[/del] or the keyboard [del]• Add a `Ball`[/del] [del]• Ball moves of its own free will[/del] (Hopefully at 45 degree angles count, all I could figure out.) [del]• Ball bounces from the top, left and right walls[/del] [del]• Ball collides with the paddle[/del] • Ball has gravity [del]• Ball resets to center of screen when falls off the bottom[/del] • Any other self explored coolness - Highscore system (doesn't save on quit yet) - Pausing - Togglable debug console thing - Adjustable maximum speed with left and right mouse buttons while debug console is open. - Sound effects - State of the art graphics. I've only fucked around with lua before for a day then forgot it, but was able to jump into this by looking at the getting started and callback function pages. Really easy and fun to do.
Progress. [T]http://tardis1.tinygrab.com/grabs/7cfbd517830f029e8bb5955f7fa18dd197feaede23.png[/T]
Here's my (almost) done game, scoring system is not implemented and when you destroy all the blocks it just keeps going, f1 to show debug and f2 to hide. Also it doesn't respond correctly to collisions from the sides [url]http://dl.dropbox.com/u/12347804/BreakoutClone%20v0.2b.LOVE[/url]
My entry: [media]http://www.youtube.com/watch?v=9SBYq3-mpIo&feature=player_profilepage[/media] Download link: [url]http://www.mediafire.com/?lymr8uhiy37dlak[/url] [B]Edit:[/B] I should probably tell you the controls, huh? A to move left D to move right R to reset the ball and paddle
[QUOTE=mechanarchy;32903418]You don't actually 'compile' lua code (in this case), it's interpreted. If you mean 'compile' as in shove all the stuff into a .zip file, rename it to .love and then run it, you can avoid this whole hassle by just running "love c:/path/to/game/folder/" in a command prompt. I'm doing a similar thing for mine, and it makes it much easier to just make a change, save, and then run with the new alterations without having to do the whole zip-packaging thing.[/QUOTE] You can just drag the zip file onto the LOVE icon.
[QUOTE=toaster468;32904932]You can just drag the zip file onto the LOVE icon.[/QUOTE] I was saying that you don't even need to make a zip file, you can get Love to load everything from a folder instead. That way you don't have to zip it all up and then run it, it just makes editing and testing heaps faster.
Done, unless I get my head around how gravity works without using the physics library. (Would appreciate helpful links on this.) [img]http://puu.sh/7nZA[/img] Aside from the graphical change I made highscores save and load.
Seeing people making all these breakout clones makes me wish I knew something about Lua...
Anyone wanna upload there source code so I can try to build something off it? Never done any code before and wanna try it out
Guess Ill submit this then [T]http://tardis1.tinygrab.com/grabs/7cfbd5178371d4d8b4989f36e3a47f5692ef6e3dbb.png[/T] WYSIWYG. There is no highscore system or whatever. Its all about the particles. You get 150 points for hitting the ball, -15000 points for missing. If you hit a particle, you get 0-10 points depending on how long that particle lives. I might add more effects later, but this is the first version. [URL="http://www.novaember.com/data/Breakout.love"]Download[/URL]
[url]http://pastebin.com/eNccvYcF[/url] [img]http://i.imgur.com/Kn9tu.png[/img] 2 hours worth of coding. First I ever did with LUA/love and had a lot of fun doing it. A very welcome change from all the work I've been doing for uni (CRUD system in c++ to manage a bank. Not a lot of fun...)
Sorry, you need to Log In to post a reply to this thread.