games50 / breakout Goto Github PK
View Code? Open in Web Editor NEWRemake of the classic Atari game Breakout!
Remake of the classic Atari game Breakout!
Error
main.lua:109: attempt to call global 'PlayState' (a nil value)
Traceback
[love "callbacks.lua"]:228: in function 'handler'
main.lua:109: in function main.lua:109
src/StateMachine.lua:17: in function 'change'
src/states/StartState.lua:35: in function 'update'
src/StateMachine.lua:22: in function 'update'
main.lua:139: in function 'update'
[love "callbacks.lua"]:162: in function <[love "callbacks.lua"]:144>
[C]: in function 'xpcall'
breakout.zip
i am using love11.3. the enter function of the state machine always causes problems
line 18 of statemachine.lua
(
self.current:enter(enterParams)
)
the error returned is
attempt to call method 'enter'(a nil value)
pls help me out
Error
src/states/StartState.lua:24: attempt to index local 'params' (a nil value)
Traceback
src/states/StartState.lua:24: in function 'enter'
src/StateMachine.lua:18: in function 'change'
src/states/GameOverState.lua:23: in function 'update'
src/StateMachine.lua:22: in function 'update'
main.lua:148: in function 'update'
[C]: in function 'xpcall'
-- Takes a table of user-defined colors and adapts them for version checking.
function colorLoader(colorTable)
-- Is Love2D running at version 11? Return true then, otherwise, false.
local love11 = love.getVersion() == 11
-- Pop the table in a var.
local colors = colorTable
-- For every color you put in the table,
--it should equal the first value you entered
--(the Love2D version 11 value) or else the
-- second value you entered (the alternate, old value)
for k, v in pairs(colors) do
colors[k] = love11 and v[1] or v[2]
end
-- Gimme my table back so I can use it!
return colors
end
function love.load()
-- global color table, gColors (shortened to make using it easier)
gc = {
-- Shortened, gColors{}
white = {1, 255},
darkgrey = {40/255, 40},
blue = {103/255, 103},
opaque = {1, 255},
halfalpha = {0.5, 128}
}
-- take the color table gColors and adapt it for
-- version checking, and reassign its values
-- to its adapted ones.
gc = colorLoader(gc)
end
im having trouble with my game because i keep running into the error mentioned in the title, heres my playstate.lua code:
--[[
GD50
Breakout Remake
-- PlayState Class --
Author: Colton Ogden
[email protected]
Represents the state of the game in which we are actively playing;
player should control the paddle, with the ball actively bouncing between
the bricks, walls, and the paddle. If the ball goes below the paddle, then
the player should lose one point of health and be taken either to the Game
Over screen if at 0 health or the Serve screen otherwise.
]]
PlayState = Class{__includes = BaseState}
function PlayState:init()
self.paddle = Paddle()
-- initialize ball with skin #1; different skins = different sprites
23- self.ball = Ball(1) -- this is where the error occurs
-- give ball random starting velocity
self.ball.dx = math.random(-200, 200)
self.ball.dy = math.random(-50, -60)
-- give ball position in the center
self.ball.x = VIRTUAL_WIDTH / 2 - 4
self.ball.y = VIRTUAL_HEIGHT - 42
-- use the "static" createMap function to generate a bricks table
self.bricks = LevelMaker.createMap()
end
function PlayState:update(dt)
if self.paused then
if love.keyboard.wasPressed('space') then
self.paused = false
gSounds['pause']:play()
else
return
end
elseif love.keyboard.wasPressed('space') then
self.paused = true
gSounds['pause']:play()
return
end
-- update positions based on velocity
self.paddle:update(dt)
self.ball:update(dt)
if self.ball:collides(self.paddle) then
-- reverse Y velocity if collision detected between paddle and ball
self.ball.dy = -self.ball.dy
gSounds['paddle-hit']:play()
end
-- detect collision across all bricks with the ball
for k, brick in pairs(self.bricks) do
-- only check collision if we're in play
if brick.inPlay and self.ball:collides(brick) then
-- trigger the brick's hit function, which removes it from play
brick:hit()
end
end
if love.keyboard.wasPressed('escape') then
love.event.quit()
end
end
function PlayState:render()
-- render bricks
for k, brick in pairs(self.bricks) do
brick:render()
end
self.paddle:render()
self.ball:render()
-- pause text, if paused
if self.paused then
love.graphics.setFont(gFonts['large'])
love.graphics.printf("PAUSED", 0, VIRTUAL_HEIGHT / 2 - 16, VIRTUAL_WIDTH, 'center')
end
end
any help would be appreciated, heres the traceback error too jic:
Error
src/states/PlayState.lua:23: attempt to call global 'Ball' (a nil value)
Traceback
[love "callbacks.lua"]:228: in function 'handler'
src/states/PlayState.lua:23: in function 'init'
lib/class.lua:79: in function <lib/class.lua:77>
src/StateMachine.lua:17: in function 'change'
src/states/StartState.lua:35: in function 'update'
src/StateMachine.lua:22: in function 'update'
main.lua:141: in function 'update'
[love "callbacks.lua"]:162: in function <[love "callbacks.lua"]:144>
[C]: in function 'xpcall'
I have tried to run Breakout with Love 2D 11.3 but I get error message:
Error main.lua:73: bad argument #2 to 'newSource' (string expected, got no value)
Traceback
[C]: in function 'newSource'
main.lua:73: in function 'load'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
Can anyone help?
Error
main.lua:27: module 'src/Dependencies' not found:
no field package.preload['src/Dependencies']
no 'src/Dependencies' in LOVE game directories.
no file 'src/Dependencies' in LOVE paths.
no file '.\src/Dependencies.lua'
no file 'C:\Program Files\LOVE\lua\src/Dependencies.lua'
no file 'C:\Program Files\LOVE\lua\src/Dependencies\init.lua'
no file '.\src/Dependencies.dll'
no file 'C:\Program Files\LOVE\src/Dependencies.dll'
no file 'C:\Program Files\LOVE\loadall.dll'
Traceback
[love "callbacks.lua"]:228: in function 'handler'
[C]: in function 'require'
main.lua:27: in main chunk
[C]: in function 'require'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
I am getting this error when calling the highScores from the starts screen, the params used to call the function is highScores = self.highScores
Error
src/states/HighScoreState.lua:38: attempt to index field 'highScores' (a nil value)
Traceback
src/states/HighScoreState.lua:38: in function 'render'
src/StateMachine.lua:26: in function 'render'
main.lua:203: in function 'draw'
[C]: in function 'xpcall'
Error
src/StateMachine.lua:15: assertion failed!
Traceback
[love "callbacks.lua"]:228: in function 'handler'
[C]: in function 'assert'
src/StateMachine.lua:15: in function 'change'
src/states/StartState.lua:35: in function 'update'
src/StateMachine.lua:22: in function 'update'
main.lua:138: in function 'update'
[love "callbacks.lua"]:162: in function <[love "callbacks.lua"]:144>
[C]: in function 'xpcall'
breakout.zip
When you hit a brick with the ball, the particle effects are meant to have the same colour as the brick you just hit. For me, the particles are just plain white no matter the colour of the brick. Does anyone know what's wrong?
Hey, I'm getting a visual bug where a sort of ghost line effect is seen during sprite movement (from a sprite sheet) whenever the sprite moves past / through its quad edge values.
I spent the night building an animation system that runs animations off of sprite sheets and noticed it and thought it was just my code, but then I tested it with a static, moving paddle and the same thing happens.
It's like there's an invisible grid of funny lines at each quad width / height interval that shows up on the sprite whenever it moves.
main.lua:83 bad argument #2 to newSource (string expected, got no value)
Hi, the direct source code is throwing an error on line 73. It says "bad argument, string expected, got no value", but clearly paddle_hit.wav is defined. The file exists, all is well.
But the error?
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.