cs50 / gd50 Goto Github PK
View Code? Open in Web Editor NEWSource code for games used in GD50
Source code for games used in GD50
push.lua is out of date so doesn't work with love 11.x
push.lua repo is already updated and works with love2d 11.x so file can simply be replaced
Ulydev/push@db9213b#diff-d95e747898ef40d004fd6dd0ec4a9c84)
if you use love 11.x you also need to change colours and audio.newsource lines
pong/main.lua for example needs these lines:
love.graphics.clear(.15, .17, .2, 1) (second line in function love.draw())
love.graphics.setColor(0, 1, 0, 1) ( love.graphics.setColor(0, 1, 0, 1))
sounds = {
['paddle_hit'] = love.audio.newSource('sounds/paddle_hit.wav', 'static'),
['score'] = love.audio.newSource('sounds/score.wav', 'static'),
['wall_hit'] = love.audio.newSource('sounds/wall_hit.wav', 'static')
}
after that it seems to work again.
In flappy bird player's can make the bird to fly past beyond the upper edge of the screen, so can score points and go on forever without colliding with the pipes
Example in Bird.lua 23:32
function Bird:update(dt)
self.dy = self.dy + GRAVITY * dt
if love.keyboard.wasPressed('space') then
self.dy = -5
sounds['jump']:play()
end
self.y = self.y + self.dy
end
Each dt
self.y increases. Particularly if FPS is 60 then after 2 seconds (120 frames) self.y == (VIRTUAL_HEIGHT / 2 - 8) + 2420
. In case of having 144 FPS after 2 seconds (288 frames) self.y == (VIRTUAL_HEIGHT / 2 - 8) + 5780
.
I opened a pull request #5 fixing the issue in Bird.lua
. Will add another one (if there's none) for the mario
project once I finish the module.
FYI, here's the formula of the original self.y
: (VIRTUAL_HEIGHT / 2 - 8) + (GRAVITY / FRAME_RATE) * (FRAMES * (FRAMES - 1) / 2)
. I made it like this: (VIRTUAL_HEIGHT / 2 - 8) + (GRAVITY * 60/ FRAME_RATE^2) * (FRAMES * (FRAMES - 1) / 2)
. This way self.y
should change the same over the same period of time with different frame rates. I also multiplied the "anti-gravity" burst by 60 (the original frame rate). I tested it with different refresh rates (30, 60, 144, 155) and it seems to work the same now.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.