Jon Mattson

+ Follow
since Feb 07, 2006
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jon Mattson

I don't really understand you example ritchie.

But I really wonder why my way doesn't work.

-First I make a copy of the original array:

-Then I pick values from the temp array to the original array. If i want a column to move one step up I do this:

That code is assigning the values of tempArray[i+1]["THE ACTIVE COLUMN"] to array[i]["THE ACTIVE COLUMN"]. That should move all elements in the column (except the one on the top) one step up and i think it works too. But the problem seems to be on the line
which is excecuted when (i+1 < rows) is not true which means it excecutes when the it's the last iteration of the loop. This line is supposed to take the element on the top of the column and place it on the bottom. It takes the value tempArray[0]["THE ACTIVE COLUMN"] (which is the element on the top of the column from the original order) and places it in array[rows-1]["THE ACTIVE COLUMN"] (which is according to my logic the last element in the column in the array with the new order). What i think this line does in reality is that it takes the value from the top of the column in the new order and places it in the last element in the column. But I don't get why it does that.

For me it would be entirely logical for this to work but it doesn't. Could someone explain why?

I hope you understand what I've written since english ain't my native language.


I'll still try to explain for what i need this.
I want to animate an image(a 16x16 tile for my game) of a waterfall. First I load the image to the program. Then I read it's pixeldata and place it in a 1D array. That 1D array I then convert to a 3D array which contains the alpha, red, green, blue values for each pixel. When the image is in this form I want to move the pixels from ONE column one pixel down. Then I change it back to 1D array and to a picture. I repeat this with other columns and it looks like water is falling. I want to have a method which can move the rows or columns in any direction (up, down, left, right) so I can animate other things too. If there's a faster way to move the pixels please let me know.
[ June 18, 2006: Message edited by: Jon Mattson ]
17 years ago
Well i might have been a bit unclear what i wanted.
If you press 1 while 0 is the active row this is what i want to happen:

And this is what happens:

If I press 2 when 0 is the active row, this is what I want to happen:

And this is what happens

I hope this makes it a bit clearer
[ June 15, 2006: Message edited by: Jon Mattson ]
17 years ago
So I need a method which moves the elements in a column one step up or down and the elements in a row left or right.

I've made this program to test it:

You can compile it and run it. With left and right you change columns and up and down you change rows. With 1 you move the active row 1 step left, with 2 one step right. With 3 you move active column one step up, with 4 one step down.

As you see when moving the elements left or up the first and last element becomes the same. If you move right or down all elements become the same.
I need to do this to make an animation with an image.

When moving up i think the problem could be on this line:

Since its the last element that is wrong. It's like tempArray[0][index1] would have the same value as array[0][index1] which gets changed right in start. I think the problems with moving down or right would be fixed if I knew what was wrong here.

Replies appriciated, been many hours about this.
[ June 15, 2006: Message edited by: Jon Mattson ]
17 years ago
So what's the right forum?

I found an example somewhere where pixelgrabber was used to get a 1D array of the pixels from an image. Then the 1D array was converted to a 3D array which contained the red, green, blue and alpha value for each pixel.

I got a couple of questions about this:

First I think the page was pretty old and there might be something else I can use, is there?

Second if pixelgrabber is the best way then how does it really work the example I got worked well but when I tried to integrate it to my own code it didn't work.

I'm talking about this page

Replies appreciated
[ June 12, 2006: Message edited by: Jon Mattson ]
17 years ago
I'd like to know what's the fastest way to move a column of pixels one pixel down so that the lowest pixel comes out on top. I'm now talking about 16x16 tiles for my game. It should be fast enough so that you can do it every frame keeping 60 fps. Is this possible and how?
17 years ago
I just checked the diffrent forums in here and this programmer certification one has alot of posts. Does someone care to explain what SCJP is?
Well i don't really understand what u want but here is what i did. Now the computer stops when it hits the wall. I don't think it's a good idea to use timers for this. I think a game loop would be better. Also you should fix that flickering by drawing everything to an off screen image and then drawing that image to screen.

17 years ago
I want to make a program in which you can create rectangles and specify their width and length and then move them around with the mouse. How should I do this? How can I make new objects at runtime? I have heard people talking about linked lists, what are they and how do I use them?

Thanks in advance
17 years ago
Already edited that out
I mean that that is the simplest way to get a program running. You don't need to change any paths and stuff.

Using Eclipse now which solves all problems
17 years ago
You are supposed to write the lines javac and java Helloworld in the command line.

javac compiles your .java file which has your code. It creates a .class file for you.

java Helloworld runs the class file

You must using the command line go to the bin folder in which you have java.exe and javac.exe. You should also have your file here.
After that you can write those 2 commands in the command line.

You say you use JCreator, never used it but atleast the Eclipse IDE got a button with which you can run your code. Also i hope you got the HelloworldFrame class otherwise that wont compile.
[ April 23, 2006: Message edited by: Jon Mattson ]
17 years ago
Well actually AudioClip loopClip; and SoundList soundList; wasn't supposed to be there. I first tried using them at first but I didn't succeed. Like how do you load the audio file to that AudioClip? AudioClip is an interface so how am i supposed to use it? There are like 10 classes that start with Audio in the API but i don't really get how to use them.
17 years ago
I'm wondering how to make a midi file loop in a application.
I managed to make a file play once like a month ago, i took some code from some example and got it to work somehow.

Here are some lines from that code:

I would like to get it so that i can from my game loop change the file being played. Any ideas? :roll:
17 years ago
How do I make a textfield in which you only can type numbers into, like pressing a letter wouldn't do anything. I've checked the FormattedTextField tutorial but I don't really understand how to use it to make this.

Any ideas?
18 years ago
I'd like to load four equal sized images from .png files and combine them to one big image. How do I do that?

I tried by painting all four images to a Graphic but I didn't find a way to convert a Graphic to an Image, is there a way?
18 years ago
Sweet it's working now, thx alot

Now I've been trying to make it able to save the text. I wrote some code but it doesn't seem to work. It saves a file but it's empty. If I load a file and save it without changing anything it works.

Here is the code:

I also tried using PrintWriters methods print(string) and write(string) but they didn't work either.
18 years ago