Pasting data between arrays

For questions about using Classic.

Post » Tue Mar 29, 2011 10:54 pm

Right I can tell this is going to make zero sense to anyone but I'll try.

I have two arrays one is 150x150 in size and the other is 20x20. The screen size is 150,150 so the larger array represents each pixel on screen.

I'm trying to put the data (is loaded from a saved array and is either 1 or 0 nothing complicated) from the smaller one (array2) into the larger (array1) where the left mouse button is clicked but it doesn't seem to work properly. It pastes the data but nowhere near where the mouse is clicked. I've probably mucked up maths wise but this is bugging me now. What I've tried:

On mouseclick I set 2 global variables to the mouse X&Y when clicked.

For Each element array2
current index is 1 set array1 currentindex + Xvariable & currentindey + Yvariable to 1

In my mind if the current index is 10,10 and the mouse is clicked at 50,50 it should set the data in the larger array to 1 at 60,60.

Don't really want to post a cap as it's very messy at the moment but can anyone see what is going to be my simple mistake.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Tue Mar 29, 2011 11:11 pm

Not sure if it's just the pseudo code you've posted, but it doesn't look like you're checking the value at x,y, but instead just using a single currentindex.

Other than that, check you're using the correct type of mouse coords.

It looks like it should work otherwise.

Krush.
B
2
S
2
G
3
Posts: 406
Reputation: 2,062

Post » Tue Mar 29, 2011 11:20 pm

Yeah it's my pseudo code I check if the value of the small array is 1 then set the value in the larger array as 1. If the small array value is 0 I set the larger array value as 0.

I'm going to keep trying this as I'm sure it's so simple that I can't see the problem for looking.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Tue Mar 29, 2011 11:47 pm

Ok I sussed it. Well sort of.

I recreated my events but used sprites instead of colouring pixels with the Image Manipulator and it pastes my data where it should be. Well for now it seems.

I'll probably find a way to break it again at a later date. :)
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Tue Mar 29, 2011 11:51 pm

Ah, another image manipulator bug perhaps?
B
2
S
2
G
3
Posts: 406
Reputation: 2,062

Post » Wed Mar 30, 2011 1:35 am

I didn't test it with the actual version, but in v96 the vertical coordinate of the image manipulator is turned upside down. 0 being the bottom of the image instead of the top. That might have caused it?
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Wed Mar 30, 2011 8:43 am

[quote="tulamide":7ggi912a]I didn't test it with the actual version, but in v96 the vertical coordinate of the image manipulator is turned upside down. 0 being the bottom of the image instead of the top. That might have caused it?[/quote:7ggi912a]

That sounds like what I was experiencing.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests