## Array problem

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Mateus
Prole
Posts: 42
Joined: Sat Apr 04, 2015 1:02 pm

### Array problem

Does anyone know how to fix this issue?

Code: Select all

if Slider[3].stop ~= 1 then
for k,v in ipairs(Slider[3]) do

if v.y > -500 and v.y < 10 and spinTimer <= Slider[3].spinTime then
Slider[3].lastID = k
end
if Slider[3][Slider[3].lastID].y <= 300-GameSpeed then

v.y = v.y + GameSpeed
elseif spinTimer >= Slider[3].spinTime then
Slider[3].stop = 1
love.audio.stop(sounds[11])
love.audio.play(sounds[11])

if Slider[3].multiplaySymbol == 1 then
love.audio.stop(sounds[17])
love.audio.play(sounds[17])
end
end

if v.y > 638 then
v.y = v.y - GameSizeY*5
v.item = getRandom(3)
end
end


Nelvin
Party member
Posts: 108
Joined: Mon Sep 12, 2016 7:52 am
Location: Germany

### Re: Array problem

It would be a good idea to at least try to describe the actual problem/issue.

Mateus
Prole
Posts: 42
Joined: Sat Apr 04, 2015 1:02 pm

### Re: Array problem

in the video, you can see the symbols are getting offset each spin. And thats the problem.

Nelvin
Party member
Posts: 108
Joined: Mon Sep 12, 2016 7:52 am
Location: Germany

### Re: Array problem

I see ... if I understand your code correctly it probably is because you move the symbols y position by the value of GameSpeed and at some point reset this position by subtracting 5*GameSizeY which results in different stopped y positions if 5*GameSizeY is not an exact multiple of GameSpeed.
You could either fix the positions when you stopp the symbols or reset them to a fixed position instead of a relative reset, i.e. v.y = GameSizeY*5 or whatever is the correct position.

Mateus
Prole
Posts: 42
Joined: Sat Apr 04, 2015 1:02 pm

### Re: Array problem

Nelvin wrote:
Tue Jan 01, 2019 2:00 pm
I see ... if I understand your code correctly it probably is because you move the symbols y position by the value of GameSpeed and at some point reset this position by subtracting 5*GameSizeY which results in different stopped y positions if 5*GameSizeY is not an exact multiple of GameSpeed.
You could either fix the positions when you stopp the symbols or reset them to a fixed position instead of a relative reset, i.e. v.y = GameSizeY*5 or whatever is the correct position.