I have a glitch in my game

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
MaxGamz
Party member
Posts: 100
Joined: Fri Oct 28, 2022 3:09 am

I have a glitch in my game

Post by MaxGamz »

So I want to make a 2 player sports game and I finished creating the code for player 1. I had no issues but when I implemented the code for the second player, I started to get bugs. The animations for the players change depending on the movement of one of the players and the animations are moving way faster for some reason. I checked my code and it seemed to be just fine.

Here is my project
Attachments
Game.love
(200.31 KiB) Downloaded 52 times
Xugro
Party member
Posts: 110
Joined: Wed Sep 29, 2010 8:14 pm

Re: I have a glitch in my game

Post by Xugro »

The variable currentAnim is a global variable that is shared by player.lua and polly.lua. Do not use globals for animations, but class fields instead:

Code: Select all

function Polly:animations() -- loads in animations
    local g = self.grid
    self.idle = anim8.newAnimation(g(("1-4"), 1), 0.1)
    self.runAnim = anim8.newAnimation(g(("6-9"), 1), 0.1)
    self.jumpAnim = anim8.newAnimation(g((11), 1), 0.1)
    self.fallAnim = anim8.newAnimation(g((10), 1), 0.1)
    self.currentAnim = self.idle
end
MaxGamz
Party member
Posts: 100
Joined: Fri Oct 28, 2022 3:09 am

Re: I have a glitch in my game

Post by MaxGamz »

Thanks! I didn't think that was the issue. It works perfectly now
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 57 guests