Page 1 of 1

Array problem

Posted: Sun Dec 30, 2018 9:46 pm
by Mateus
[youtube]https://www.youtube.com/watch?v=-RLx19QX2LI[/youtube]

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

Re: Array problem

Posted: Mon Dec 31, 2018 10:00 am
by Nelvin
It would be a good idea to at least try to describe the actual problem/issue.

Re: Array problem

Posted: Tue Jan 01, 2019 12:12 pm
by Mateus
in the video, you can see the symbols are getting offset each spin. And thats the problem.

Re: Array problem

Posted: Tue Jan 01, 2019 2:00 pm
by Nelvin
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.

Re: Array problem

Posted: Sat Jan 12, 2019 8:22 pm
by Mateus
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.
Thank you for your answer!