• Gwilty's Programming Assignments #1
    355 replies, posted
Like my school assignments Absolute minimum: [url]http://cold.netburst.co.uk/file/2011.10.24-17.24.04.txt[/url]
[QUOTE=Paulendy;32940020]Well this isn't really a breakout clone, it's more like lonely vertical pong. [url]http://dl.dropbox.com/u/5324647/Lonely%20Pong.love[/url] Also please don't kill my dropbox. :saddowns:[/QUOTE] I can see you used some of my code :v: anyway good job!
There's a major flaw with the ball only flipping direction horizontally and vertically, being that the game will be exactly the same every time you play.
Try changing the bounce angle depending on where on the paddle the ball collides then. :v: Also don't forget about implementing gravity. Has anyone accomplished that yet? (besides using love.physics) The principle is simple - Gravity in this simplified context can just be a constant downwards acceleration applied to the ball. Acceleration by definition is "a change in velocity per second applied every second", so you just want to be adding your gravity value (properly reduced to represent only the amount of time passed since the last update) to your y speed value every update.
[QUOTE=ElTacoLad;32941590]There's a major flaw with the ball only flipping direction horizontally and vertically, being that the game will be exactly the same every time you play.[/QUOTE] You can randomize the initial conditions when the game starts.
I'm going to make mine into a full game too. It's going to be called 'Not Sexy Breakout' and it'll have pictures of girls undressing depending on the players score. :V
[QUOTE=DeadKiller987;32942226]I'm going to make mine into a full game too. It's going to be called 'Not Sexy Breakout' and it'll have pictures of girls undressing depending on the players score. :V[/QUOTE] I only see one flaw in there: Where do you get an undressing girl from?
His mum normally helps out with his projects. Onto the bricks now and scoring, thiss is quite fun actually.
I'm a bit late to the party, but I am going to work on this today. First I wrote a engine wrapper for LÖVE so I can cache images and make spritesheets super easy. Main.lua [img]http://i.imgur.com/RNEeD.png[/img] Player:New [code]Function: new Description: Create new Player object Args: 4 - x: Default player X - y: Default player Y - spritesheet: Spritesheet object[/code] Spritesheet:New [code]Function: new Description: Create new Spritesheet object Args: 2 - spritesheet: Spritesheet to be rendered - tilesize: Size of each Tile in Spritesheet[/code] And then Engine.lua [img]http://i.imgur.com/8Bcpc.png[/img] This should make everything super fast.
[QUOTE=subenji99;32942113]Try changing the bounce angle depending on where on the paddle the ball collides then. :v: Also don't forget about implementing gravity. Has anyone accomplished that yet? (besides using love.physics) The principle is simple - Gravity in this simplified context can just be a constant downwards acceleration applied to the ball. Acceleration by definition is "a change in velocity per second applied every second", so you just want to be adding your gravity value (properly reduced to represent only the amount of time passed since the last update) to your y speed value every update.[/QUOTE] I've already solved the problem, and implemented gravity. I posted a video back on page 3. [B]Edit:[/B] To i300, what editor is that? It looks sexy, and I'm just using Notepad++.
[QUOTE=ElTacoLad;32943183]I've already solved the problem, and implemented gravity. I posted a video back on page 3. [B]Edit:[/B] To i300, what editor is that? It looks sexy, and I'm just using Notepad++.[/QUOTE] Sublime Text 2 with Monokai theme. (Monokai comes installed with Sublime Text 2)
New version of my Sort-of Breakout: [url]http://www.mediafire.com/?lymr8uhiy37dlak[/url] Changes: Nicer Paddle Movement Score System (I wouldn't call it a system if I could think of something else to call it)
[QUOTE=PieClock;32923128] [QUOTE=TheDecryptor;32922136]I did the "physics" on the ball by storing the position and velocity, then inverting the velocity when it hit something (Invert X direction when it hit a side wall, Y direction if it hit the top/paddle)[/QUOTE] I feel stupid now. That sounds a lot easier than my rules for the 45 degree angle stuff.[/QUOTE] Haha, oh wow, it was. Before: [url]http://pastebin.com/WaJBwVAm[/url] After: [url]http://pastebin.com/nSejd9gA[/url] :v:
[QUOTE=i300;32943179]And then Engine.lua [img]http://i.imgur.com/8Bcpc.png[/img] This should make everything super fast.[/QUOTE] The idea of an engine abstraction on top of love is great; it's also what I'm doing, but in the picture above, you're taking a step back. Rather than loading up the individual modules from the love module and loading them into an engine table, you're better off just creating local references to the modules within each file you use. This is the fastest method.
Speaking from lots of experience using and benchmarking LÖVE and Lua stuff, there's absolutely no reason to do any sort of local variable caching purely for the sake of performance, unless you somehow need 1.50ms frame time instead of 1.51 or whatever. It usually causes unnecessary confusion and problems for the sake of a perceived performance benefit which, in practice, will rarely do anything because most performance drops in LÖVE stem from the graphics side of things.
Okay so I found this off of someone: [CODE]local ball = {} ball["x"] = graphics.getWidth()/2 ball["y"] = graphics.getHeight()/2 ball["vx"] = math.random(-100, 100) ball["vy"] = math.random(50, 100) ball["radius"] = 20[/CODE] Just to be clear. This is essentially making a new 'ball' without actually making a ball class, and assigning properties to it? It is essentially the same as doing [CODE]ball.x = ... ball.y = ...[/CODE] correct?
[QUOTE=amcfaggot;32944093]The idea of an engine abstraction on top of love is great; it's also what I'm doing, but in the picture above, you're taking a step back. Rather than loading up the individual modules from the love module and loading them into an engine table, you're better off just creating local references to the modules within each file you use. This is the fastest method.[/QUOTE] I'm honestly making this for me. I have always worked with an engine constant (usually a class or a table). I also dont like reserving keywords for variables like "graphics", "keyboard", "mouse", and especially "images".
Improved it: [url]http://www.pixellegacy.com/extremeballbouncing.love[/url] Changelog: -Fixed a glitch where the ball and/or paddle would destroy themselves (i still don't know how it did that) -Background music added, along with a info file with info about it. -Sound effects added but i doubt you can hear them over the background music. -Threw in one of the default particle systems because i don't want to modify one at the moment, but i did minorly tweak it -BGcolor is amazing now. (can't see it in the screenshot) -You get 50 points per block broken, and 1 point each time you bounce the ball off of the paddle Still broken: -Sometimes the ball goes through bricks [img]http://img197.imageshack.us/img197/8541/screenshot2011102415362.png[/img]
Working on this between classes (i.e. 15 minutes at a time, a hour or so in total). [img]http://i.imgur.com/O0avY.png[/img] Going for a retro look right now.
[QUOTE=HeroicPillow;32945151]Improved it: [url]http://www.pixellegacy.com/extremeballbouncing.love[/url] Changelog: -Fixed a glitch where the ball and/or paddle would destroy themselves (i still don't know how it did that) -Background music added, along with a info file with info about it. -Sound effects added but i doubt you can hear them over the background music. -Threw in one of the default particle systems because i don't want to modify one at the moment, but i did minorly tweak it -BGcolor is amazing now. (can't see it in the screenshot) -You get 50 points per block broken, and 1 point each time you bounce the ball off of the paddle Still broken: -Sometimes the ball goes through bricks [img]http://img197.imageshack.us/img197/8541/screenshot2011102415362.png[/img][/QUOTE] You should add a mute button.
[QUOTE=nath2009uk;32945495]You should add a mute button.[/QUOTE] It's ambience. [sp]Maybe later when i figure out a better way to handle the ball collision that doesn't suck so bad.[/sp] edit: uploaded a new version with a mute button...
Took about 30 min. First time using LOVE/Lua. [video=youtube;cTMihRPpQN0]http://www.youtube.com/watch?v=cTMihRPpQN0[/video] Am I supposed to use delta time? Cause I didnt.
[QUOTE=Darkest_97;32945584]Am I supposed to use delta time? Cause I didnt.[/QUOTE] Yes. Turn off vsync and that'll be way too fast to play.
[QUOTE=BlkDucky;32945792]Yes. Turn off vsync and that'll be way too fast to play.[/QUOTE] Oh I see the problem. So love.update always gives me dt? So basically I have to only allow everything in update to happen if dt has reached a certain number of seconds?
[code] y2 = y2 + (ballspeed * dt) x2 = x2 + (ballspeed * dt) if y2 < 0 then ballspeed = 200 end if x2 < 0 then ballspeed = 200 end if y2 > 400 then ballspeed = -200 end if x2 > 500 then ballspeed = -200 end end function love.draw() g.setColor(255,0,0,255) g.rectangle("fill", x, y, 80, 20) g.setColor(0,0,0,255) g.circle("fill",x2,y2,10,10) end [/code] Anyone know why this isn't working? It just bounces from the bottom right to the top left.
You're using the same speed value for both horizontal and vertical movement.
[QUOTE=Darkest_97;32946272]Oh I see the problem. So love.update always gives me dt? So basically I have to only allow everything in update to happen if dt has reached a certain number of seconds?[/QUOTE] Treat your speeds as "pixels per second" and then multiply them by dt when adding speed to position, that way they will actually be in pixels per second. For example: x = x + speed * dt
[QUOTE=slime73;32947051]Treat your speeds as "pixels per second" and then multiply them by dt when adding speed to position, that way they will actually be in pixels per second. For example: x = x + speed * dt[/QUOTE] I kept seeing people using 'x = x + speed * dt' but I didnt understand it and it worked fine my way. But now I see how it works thanks. Fixes the vsync problem, even though I have no idea what it means.
[QUOTE=subenji99;32946778]You're using the same speed value for both horizontal and vertical movement.[/QUOTE] Thanks so much. Now I just need to figure out collision. Anyone know how to assign drawn objects to variables to test if their y numbers match?
I've tried to use dt, but I just get errors because it doesn't know what dt is.
Sorry, you need to Log In to post a reply to this thread.