This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-04-18 11:15:40

Smozzick
Scratcher
Registered: 2011-10-23
Posts: 100+

Maths help for my map code please

Hi, I'm working on a game called Resource War for the SC13 competition held by ROSman and I've come across a bug.


The Problem
Clicking on a unit card (the first one, specifically, at the moment) takes you to the unit which is correct but on some parts of the map you are moved to the wrong area. See code in RUnit1 marked THE PROBLEM to see where the maths is messed up.

If anyone could help I'd be very greatful and be sure to credit you in the notes ^^

Last edited by Smozzick (2013-04-18 11:42:31)


http://i50.tinypic.com/ded8m.png

Offline

 

#2 2013-04-18 15:57:56

Smozzick
Scratcher
Registered: 2011-10-23
Posts: 100+

Re: Maths help for my map code please

bump


http://i50.tinypic.com/ded8m.png

Offline

 

#3 2013-04-18 16:45:21

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Maths help for my map code please

Smozzick wrote:

bump

Okay, so from a quick overview of your code, apparently the problem that's causing this is that your person is technically in a "block", though since it's at the top, your equation thinks that it's a block higher, giving you this glitch. If you do a bit of testing yourself, you'll notice that if you put your person in row 2, yet have him below a YPos of 430, this glitch won't occur. The same holds true with row 1 and a YPos below 90.

Also, this glitch doesn't just occur below row 3. It happens everywhere.

Anyway, I'm going to need a bit more time and testing before I can find the source of this glitch.

With regards,

ErnieParke

Last edited by ErnieParke (2013-04-18 17:01:08)


http://i46.tinypic.com/35ismmc.png

Offline

 

#4 2013-04-18 17:18:21

Smozzick
Scratcher
Registered: 2011-10-23
Posts: 100+

Re: Maths help for my map code please

ErnieParke wrote:

Smozzick wrote:

bump

Okay, so from a quick overview of your code, apparently the problem that's causing this is that your person is technically in a "block", though since it's at the top, your equation thinks that it's a block higher, giving you this glitch. If you do a bit of testing yourself, you'll notice that if you put your person in row 2, yet have him below a YPos of 430, this glitch won't occur. The same holds true with row 1 and a YPos below 90.

Also, this glitch doesn't just occur below row 3. It happens everywhere.

Anyway, I'm going to need a bit more time and testing before I can find the source of this glitch.

With regards,

ErnieParke

Just tried something that looks like it might work. I changed the maths to:

<<<<[1290] - <<(ypos) - <<(ypos) - [180]> mod [258]>> - [180]>> / [258]> - [1]> * [6]>
for the y part. In the cell section that now gives me the correct cell so with any luck it should work...

Put it in without the *6 in the part with the main problem and it seems to work. Thanks for the help! I hadn't noticed that it was on different parts of the view so I wasn't sure where the problem was.

Last edited by Smozzick (2013-04-18 17:23:15)


http://i50.tinypic.com/ded8m.png

Offline

 

#5 2013-04-18 18:21:49

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Maths help for my map code please

Smozzick wrote:

ErnieParke wrote:

Smozzick wrote:

bump

Okay, so from a quick overview of your code, apparently the problem that's causing this is that your person is technically in a "block", though since it's at the top, your equation thinks that it's a block higher, giving you this glitch. If you do a bit of testing yourself, you'll notice that if you put your person in row 2, yet have him below a YPos of 430, this glitch won't occur. The same holds true with row 1 and a YPos below 90.

Also, this glitch doesn't just occur below row 3. It happens everywhere.

Anyway, I'm going to need a bit more time and testing before I can find the source of this glitch.

With regards,

ErnieParke

Just tried something that looks like it might work. I changed the maths to:

<<<<[1290] - <<(ypos) - <<(ypos) - [180]> mod [258]>> - [180]>> / [258]> - [1]> * [6]>
for the y part. In the cell section that now gives me the correct cell so with any luck it should work...

Put it in without the *6 in the part with the main problem and it seems to work. Thanks for the help! I hadn't noticed that it was on different parts of the view so I wasn't sure where the problem was.

Well, at least now you know where it is, and you're welcome! By the way, good luck with your game!  smile

With regards,

ErnieParke


http://i46.tinypic.com/35ismmc.png

Offline

 

#6 2013-04-18 18:26:56

Smozzick
Scratcher
Registered: 2011-10-23
Posts: 100+

Re: Maths help for my map code please

Thanks ^^


http://i50.tinypic.com/ded8m.png

Offline

 

Board footer