• Gwilty's Programming Assignments #1
    355 replies, posted
[QUOTE=Bambo.;32894967][code] -- when moving left if paddlex >= 0 then -- move paddle left end -- when moving right if (paddlex + paddle width) <= 650 thn -- move paddle right end [/code] but make sure you compensate for the width.ect when moving right ( depending on what you are using )[/QUOTE] This is pretty much what I got, but that doesn't stop the pad from moving 0-5 pixels out of the screen, since it moves more than 1 pixel each update. [editline]21st October 2011[/editline] [QUOTE=Sc00by22;32894995]Check the position and if it goes above or below the screen size stop it from moving, or above.[/QUOTE] I'll try that! Thanks. EDIT: Yeaaas! got it working :-)
[lua]if paddlex < 0 then paddlex = 0 elseif paddlex + paddlew > love.graphics:getWidth() then paddlex = love.graphics:getWidth() - (paddlex + paddlew) end[/lua] ?
[IMG]http://dl.dropbox.com/u/12347804/besten.png[/IMG] [editline]21st October 2011[/editline] [QUOTE=BlkDucky;32895139][lua]if paddlex < 0 then paddlex = 0 elseif paddlex + paddlew > love.graphics:getWidth() then paddlex = love.graphics:getWidth() - (paddlex + paddlew) end[/lua] ?[/QUOTE] [lua] if love.keyboard.isDown("left") then if math.floor(xPaddle) > 0 then xPaddle = xPaddle - speedPaddle * dt end end if love.keyboard.isDown("right") then if math.floor(xPaddle) < 740 then xPaddle = xPaddle + speedPaddle * dt end end [/lua] this is how I did it
[QUOTE=BlkDucky;32895139][lua]if paddlex < 0 then paddlex = 0 elseif paddlex + paddlew > love.graphics:getWidth() then paddlex = love.graphics:getWidth() - (paddlex + paddlew) end[/lua] ?[/QUOTE] Why would you do ([B]paddlex[/B] + paddlew) in line 4?
Guys how do I collision between two images
[QUOTE=Eric95;32895384]Guys how do I collision between two images[/QUOTE] [lua] function CheckCollision(box1x, box1y, box1w, box1h, box2x, box2y, box2w, box2h) if box1x > box2x + box2w - 1 or -- Is box1 on the right side of box2? box1y > box2y + box2h - 1 or -- Is box1 under box2? box2x > box1x + box1w - 1 or -- Is box2 on the right side of box1? box2y > box1y + box1h - 1 -- Is b2 under b1? then return false -- No collision. Yay! else return true -- Yes collision. Ouch! end end [/lua]
I got started on something like this on my calculator in math class last year, but I only worked on it in class and only during the last couple weeks of school. I didn't finish it, but I had the "paddle" and the "ball" working separately; all I needed was to add some "collision detection" and decide how to score it.
[QUOTE=Maurice;32895325]Why would you do ([B]paddlex[/B] + paddlew) in line 4?[/QUOTE] yeah, good point. Needless to say, I didn't test this. That should just be love.graphics:getWidth() - paddlew.
[QUOTE=FlashStock;32895396][lua] function CheckCollision(box1x, box1y, box1w, box1h, box2x, box2y, box2w, box2h) if box1x > box2x + box2w - 1 or -- Is box1 on the right side of box2? box1y > box2y + box2h - 1 or -- Is box1 under box2? box2x > box1x + box1w - 1 or -- Is box2 on the right side of box1? box2y > box1y + box1h - 1 -- Is b2 under b1? then return false -- No collision. Yay! else return true -- Yes collision. Ouch! end end [/lua][/QUOTE] How do I assign width and height parameters to my images? And how do I take use of a function like that in my update? I can't even figure out how to do a simple boolean, can't find anything in the wiki
[QUOTE=Eric95;32895641]How do I assign width and height parameters to my images? And how do I take use of a function like that in my update? I can't even figure out how to do a simple boolean, can't find anything in the wiki[/QUOTE] image:getWidth() and image:getHeight() returns what you would expect. [editline]21st October 2011[/editline] also the wiki is for LOVE. Not lua. So there's nothing about the actual language.
[QUOTE=BlkDucky;32895700]image:getWidth() and image:getHeight() returns what you would expect. [editline]21st October 2011[/editline] also the wiki is for LOVE. Not lua. So there's nothing about the actual language.[/QUOTE] Oh. Well dangit, then. Tried looking at the link on the first page but the boolean part never stated how to state a boolean, so I don't know. Also image:getWidth()? I have no idea where to put it :smith:
[QUOTE=Eric95;32895791]Oh. Well dangit, then. Tried looking at the link on the first page but the boolean part never stated how to state a boolean, so I don't know. Also image:getWidth()? I have no idea where to put it :smith:[/QUOTE] variable = true -- or false I suggest looking through this love file [url]http://commondatastorage.googleapis.com/loveclub/examples.love[/url] Research the source code.
Well there's everything required in here but I don't know what to add :< [img]http://i51.tinypic.com/m96o91.png[/img] (That's right, you're in space!!!) [by the way I didn't use any image files!]
[video=youtube;TkVhK88_d9A]http://www.youtube.com/watch?v=TkVhK88_d9A[/video] I feel so proud. :v:
[QUOTE=Osherzz;32895842]Well there's everything required in here but I don't know what to add :< (That's right, you're in space!!!) [by the way I didn't use any image files!][/QUOTE] But... but... there's no gravity in space! The fundamentals of the game would never work! (just kidding of course, looks good. Especially if this is a first project)
eh, i started with hello world in c++ but i guess his would do too.
[QUOTE=FlashStock;32895834]variable = true -- or false I suggest looking through this love file [url]http://commondatastorage.googleapis.com/loveclub/examples.love[/url] Research the source code.[/QUOTE] Okay, thanks. Wish it had an example for collision detection though because I still can't get that working
[QUOTE=Eric95;32896301]Okay, thanks. Wish it had an example for collision detection though because I still can't get that working[/QUOTE] For a breakout game, a rectangle collision isn't a good idea anyway. You could move your paddle all over the place and it'd always hit the ball. Instead, check if the ball is crossing a Y value at the current update, and if so check if the X value is where the paddle is.
[QUOTE=Maurice;32896404]For a breakout game, a rectangle collision isn't a good idea anyway. You could move your paddle all over the place and it'd always hit the ball. Instead, check if the ball is crossing a Y value at the current update, and if so check if the X value is where the paddle is.[/QUOTE] Ok, thanks. Anyway I'll stop hijacking this thread now
Friday night programming, mothafuckas! Intro screens. Represent. [t]http://i.imgur.com/Qg6hI.png[/t] [t]http://i.imgur.com/tiEOb.png[/t]
[QUOTE=amcfaggot;32896628]Friday night programming, mothafuckas! Intro screens. Represent. [t]http://i.imgur.com/tiEOb.png[/t][/QUOTE] Maurice is gon sue someone
I think I'll participate too, but using C# & SFML instead. Happy coding everyone :)
My progress [video=youtube;5jtZQShj0fw]http://www.youtube.com/watch?v=5jtZQShj0fw [/video] EDIT: Video tags, how do they work?
Can't get sounds to play more than once. Sound effects -- scratched off my list.
[QUOTE=Felheart;32896888]I think I'll participate too, but using C# & SFML instead. Happy coding everyone :)[/QUOTE] I think you're missing the whole point of expanding your knowledge
[QUOTE=Osherzz;32897220]I think you're missing the whole point of expanding your knowledge[/QUOTE] not if he's a C# noob
I have collision code that mostly works, but if I move the paddle in such a way that the ball collides with the side of it I can get the ball to bounce endlessly [i]inside[/i] the paddle. Is there any easy way of avoiding this or should I just do the cheap hacky way and reset the ball's y-value when it collides?
Got SFX to work again. Fun to work with Love again. Pun intended.
I've just finished mine. I will maybe add some feature because it's really generic. -snip see below-
Why/how did you record/save as FLV? Save it as an ogg :v: [editline]21st October 2011[/editline] ogv [editline]21st October 2011[/editline] I converted it for you: [vid]http://dl.dropbox.com/u/4992578/output.ogv[/vid]
Sorry, you need to Log In to post a reply to this thread.