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 / [SOLVED] Help with sprite positions

Author
Message
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 8th Dec 2022 23:31 Edited at: 8th Dec 2022 23:40
Ok so I am trying something new and different and practicing new ways of doing things.

I have a grid of sprites, marbles lined up together on a grid and I can move each one to my pointer if selected, but I need to limit how far I can move them
due to there past positions and cell size. I am trying one way and it works but only for one side of its x pos and not the other.

Here is a example of my code.



I tried many things, even this but it does not work for both sides.

if gride[x,y].Newposx<gride[x,y].oldposx+CELL_SIZE or gride[x,y].Newposx>gride[x,y].oldposx+CELL_SIZE then SetSpritePositionByOffset(gride[x,y].sprite, GetPointerX ( ), GetPointerY ( ))

I fell like it is so simple but I do not see it.

Thanks for any help of understanding on this.

In case anyone is wondering I am setting up different games in my match three game and this is one of the other games. You have to move each marble over the pets then they drop on them and explode. but they have to be limited to only the next slot over from there own position.

This is the whole function I created if it helps.

The author of this post has marked a post as an answer.

Go to answer

fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 9th Dec 2022 02:56
Im not sure if this is what you are after but i did notice that getspritehittest didnt work but getspritehit did for some reason

The code above allows moving they just dont snap into place
fubarpk
https://fubarpk.itch.io/
Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 9th Dec 2022 13:35 Edited at: 9th Dec 2022 13:36
Hi fubarpk

Thanks for looking.

It made no difference.

What I am looking for is limited movement for the marbles. Do you see how they can not move to the right past there neighbor? that is how I need it for left to right to up and down. They can move, but only only slot.

Let me say you put together a whole example, that was nice.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Dec 2022 16:29
This post has been marked by the post author as the answer.
Taking a guess here based on your first snippet, your method only works to the RIGHT because that's a positive quadrant. You should check the absolute values instead, then the same check can work for both directions

Try something like this
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda
Pixel-Perfect Collision

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Game_Code_here
4
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 9th Dec 2022 16:55
Quote: "You should check the absolute values instead"


Yes this is true, Also it works and I can now implement the new mini game, thank you for the great answer.

Login to post a reply

Server time is: 2024-11-23 09:31:58
Your offset time is: 2024-11-23 09:31:58