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.

Newcomers DBPro Corner / Help moving 2D Image

Author
Message
gameangel147
11
Years of Service
User Offline
Joined: 2nd Dec 2012
Location:
Posted: 2nd Dec 2012 11:21
I am trying to get an image to move, but so far it only moves a certain distance, it doesn't continually move.



I have just started getting into functions and images so this is new territory. I have been able to get a box to move left and right but the image only moves however much I increase or decrease. I have tried Move Sprite but had no luck, though not sure if I need to make it a sprite first.

Any help would be appreciated and I apologize if I posted this wrong somehow, also my first time posting on the forums.
Darkhog
11
Years of Service
User Offline
Joined: 25th Nov 2012
Location: Mushroom Kingdom
Posted: 2nd Dec 2012 15:11
First of all, you load image continuously. Please move load image at beginning of program, between imgPlayer = 1 and repeat. Same for imgX/imgY.

Here, that should work:


WHAT WAS WRONG
First of all, you loaded image every loop iterations which has severe impact on speed of your code. This wasn't critical and didn't relate to your problem at all, but you should know to load image at the beginning of your program, outside of main loop (you can however have "loading loop" if you have images named like img1.bmp, img2.bmp, etc. as FOR..NEXT loop).

Second thing, related to your code was you reset x and y position every iteration of loop, in picture() function that made moving picture futile. All initialization of position/speed/etc. variables should also be done outside of main loop or any function used within it.
gameangel147
11
Years of Service
User Offline
Joined: 2nd Dec 2012
Location:
Posted: 3rd Dec 2012 03:45
Aha! That did the trick! I originally had the imgX and imgY values at the top but I ran into other problems, so thanks for the help.

Login to post a reply

Server time is: 2024-11-23 17:38:49
Your offset time is: 2024-11-23 17:38:49