Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Not sure if scrolling too fast, or code is bad...

Author
Message
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 9th Apr 2019 22:20 Edited at: 11th Apr 2019 03:01
I am sure there is bad code in there. I can't figure out where I am going wrong.

If I scroll very fast to the right my sprites are not positioned correctly. I can't see anything in the code that would cause the sprites to do this.

first function called that resizes the underlying box


second function that's just a for loop that calls the function to move sprites


third function that moves the actual sprite


Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 9th Apr 2019 22:35
Well, one good thing that came out of this is that I realized I was not deleting the new image I was making while resizing the box...
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 10th Apr 2019 23:29
i see your functions but i'm not seeing what prompts you to call them. IE, are you re-calculating the number of visible rows/columns each time the pane is re-sized? and, if so, are you accounting for a ± of more than 1 sprite?

Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 11th Apr 2019 02:30 Edited at: 11th Apr 2019 02:36
Hey the first function is run every frame if the left mouse button is down, and the button was pressed while over the "edge" of the sprite. The other functions are called from the first function.

I updated the function, and its a little better. But I still get "ghost". You can see it in the video.

I know one way around it is to make the sprites invisible if past a certain X, but seems like that shouldn't be needed. Would like to learn how to code this properly. I already hack together too many fixes due to poor coding.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 11th Apr 2019 06:19 Edited at: 11th Apr 2019 06:23
i'm struggling to follow your code but, before i go to code my own, one red flag for me is your use of x# throughout.

i don't know how many times you call GetPointerX() but if it's more than once per frame, i'd suggest that it's too many. from my DBPro days, a lot of us found out the hard way that Windows doesn't care about frame rate when it comes to getting the mouse position.
IE, if you move it too fast during a frame (and you have enough going on between calls), you'll get different mouse coordinates in the same frame.

and, i could have missed it in your code, but are you properly capping x# somewhere? GetPointerX/Y() will give you coords outside of your window (assuming the mouse is outside of the window) that should be accounted for.
i don't see you doing it in the vid (on the X axis, but yes on the Y) but there was 1 instance where it was close to the far right of the screen. regardless, you're capping the left side of the pane at 2 thumbnail images from the right side but are you capping the right side properly?

i'll add: how are you getting the pane's width? then, the # of columns? it's a strict columns = width#/thumbwidth# calc, right (including whatever spacing you have going on)?

Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 11th Apr 2019 07:50 Edited at: 11th Apr 2019 07:53
Thanks for responding.

1) OK, GetPointerX() is actually captured at the start of my Do loop, and I meant to pass it to any function that needed it. I didn't pass it to this function - I will correct that. This project I am working real hard to use no globals and to not duplicate work. I missed it here. Thanks for pointing that out. Totally missed it. I changed it, but I still get the ghost effect.
2) I thought I was capping x# by this code:

It still allows the mouse to go wherever but caps the x# movement. That is my intent, anyways. Wait..... Ok.... I think I see what you mean... I will work on this tomorrow, and get back with you.

I hate to include this, because at this point I am getting a sense of spaghetti code lol - I am trying to not have globals(thank Fubar) and use "state" modes; so far I have zero globals. I think I can pull it off, but damn I am getting lost...
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 11th Apr 2019 08:02 Edited at: 11th Apr 2019 08:04
I don't think I am taking into account the width of the sprite. Will adjust and get back to you.

Thank you very much for taking your time to look at my mess. haha
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 11th Apr 2019 08:34
Quote: "I am trying to not have globals(thank Fubar)"

hahahahaha

it can be challenging at times

hopefully you get your code sorted, great things about forums theres people who often notice stuff you overlooked
and the act of often sharing it can often shed light on the subject to yourself



fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 11th Apr 2019 20:50 Edited at: 11th Apr 2019 20:51
Well, that wasn't the problem. Still not sure what is, but I put a limit on the x# position, and that solved it. If x#> limit then x# = limit. Moving on!

Login to post a reply

Server time is: 2024-11-23 01:46:21
Your offset time is: 2024-11-23 01:46:21