Array problem

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
Mateus
Prole
Posts: 42
Joined: Sat Apr 04, 2015 1:02 pm

Array problem

Post by Mateus » Sun Dec 30, 2018 9:46 pm

[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

Nelvin
Citizen
Posts: 79
Joined: Mon Sep 12, 2016 7:52 am
Location: Germany

Re: Array problem

Post by Nelvin » Mon Dec 31, 2018 10:00 am

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

Post by Mateus » Tue Jan 01, 2019 12:12 pm

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

Nelvin
Citizen
Posts: 79
Joined: Mon Sep 12, 2016 7:52 am
Location: Germany

Re: Array problem

Post by Nelvin » 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.

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

Re: Array problem

Post by Mateus » Sat Jan 12, 2019 8:22 pm

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!

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests