Page 1 of 1

Rotation Code isnt working

PostPosted: Wed Aug 01, 2007 1:34 am
by Game A Gogo
ok, I am working on something for making raphics for my game, so you can customize it, and I have placed a rotation thingy, and it doesnt work, anyone can help me out?

Problem: Its trying to read beyond allowed space.

PostPosted: Wed Aug 01, 2007 3:30 am
by DocRabbit
I'll give it a shot Game. Give me some time to look over code, been doing vba coding all day, have to get my head out of microsoft.

PostPosted: Wed Aug 01, 2007 4:22 am
by DocRabbit
Still working on, definitely somehow getting out of range on an array. Think it is mousedown on rotate, seems like somehow j is making it to a value of 16, so that is where the array is going out of bounds, just trying to figure how it is getting there.

UPDATE**
I used this method to get around the j=16, but although I didn't get the error, it blacks the canvas out. Here is a snip of the code I inserted into the switch on mousedown ROTbutton code.
Code: Select all
case 0:
                Xout=round(cos(i+(Rot/360*(PI*2))));

               Yout=round(sin(j+(Rot/360*(PI*2))));
                if(Xout<16 && Xout>=-16 && Yout<16 && Yout>=-16)
                {
                   
                   if(j!=16) Tred[Xout+16][Yout+16]=Red[i+16][j+16];
                }
                break;


What is equally strange, i behaves nicely and ends on a value of 15.

PostPosted: Thu Aug 02, 2007 2:10 am
by Game A Gogo
and also what is strange, if you take that if statement (On the unchanged code) and you revers the comparasion signs, no errors, and it freeze like, whit CPU usage at 100%

PostPosted: Thu Aug 02, 2007 3:51 am
by DocRabbit
I tried some other stuff on it late last night, and found that if you set the range on j to 15 on the high end, it comes up with 15 and no errors. The only thing I can think of that the iterations with those ifs and switch and nested fors may be taking more time that frame alotment is giving it. Maybe have makslane jump in and take a look. That code should work, and not jump past the for statement.

The black screen was the only bugger. Maybe the canvas redraw needs staggered 1 per frame draw or something. I had a similar issue and used that to get the 1 actor dynamic tiling to work.

Maybe it's moonwalking code-style.

PostPosted: Thu Aug 02, 2007 4:01 am
by DocRabbit
Oh, I meant to comment on the rest of the program. Very nice!! Even if you can't get the rotate to work, it is a very nice tile editor. very clear on mouse drawing. I get so bugged when using photoshop to do pixel work, you can't always tell if where you think you will click is where it will go. I didn't figure out all the controls, but are the small screens examples of different backdrops or choices for the backdrops? Anyways, A++ on the program. :D

PostPosted: Thu Aug 02, 2007 6:50 am
by summer_goth
Hmmm I can't seem to fix your problem yet. However I have noticed some mistakes.

To make sure that i and j are only added to 32 times:

Code: Select all
for(i=-16; i<15; i++)
{
    for(j=-16; j<15; j++)
    {


Otherwise it will go through 33 times. Or i and j will both get to 16. Oh and there was a semicolon after the for loop for j, taking that out should make a big difference.

Also in the global code I took out the semicolon after the #define:

Code: Select all
 #define PI=3.1415926535897932384626433832795


I think in this instance it won't make a difference, but it's good practice to not put semicolons after #defines.

Unfortunately I do not have the time now to go through the rest but the program looks very nice.

It's great that you are making a program such as this, however if you are just making it because you can't find a good alternative then I recommend GraphicsGale. It's perfect for pixel art and you can rotate and go crazy. Plus it's free.

You can find it here:
http://www.humanbalance.net/gale/us/

There is a version that you can buy, but that's only for some extra stuff. The free version is perfect for pixel art.

Have a great time.

PostPosted: Thu Aug 02, 2007 7:06 am
by summer_goth
I think I may have been wrong there. Try keeping it:

Code: Select all
for(i=-16; i<16; i++)
{
    for(j=-16; j<16; j++)
    {


Just make sure you take out the semicolon that was here:

Code: Select all
for(j=-16; j<16; j++);


My brain isn't working today.

PostPosted: Fri Aug 03, 2007 3:00 am
by Game A Gogo
summer_goth wrote:I think I may have been wrong there. Try keeping it:

Code: Select all
for(i=-16; i<16; i++)
{
    for(j=-16; j<16; j++)
    {


Just make sure you take out the semicolon that was here:

Code: Select all
for(j=-16; j<16; j++);


My brain isn't working today.


I don't see where you saw that semi-colon.

but here is something else, the code is more clean, and there is more feature inside the program, it can export to bitmap =D

PostPosted: Fri Aug 03, 2007 7:18 am
by summer_goth
Very nice Game A Gogo! :D

I think that maybe yesterday I added the semicolon myself by accident when I was playing with your program. Eh, sorry about that.

Glad to see that you got everything working so well.

The only problem I found is that when the rotation is set to 000 and I click on rotate then the program hangs. Eh, but it's not like someone would actually do that.

Nicely done!

PostPosted: Sat Aug 04, 2007 12:07 am
by Game A Gogo
summer_goth wrote:Very nice Game A Gogo! :D

I think that maybe yesterday I added the semicolon myself by accident when I was playing with your program. Eh, sorry about that.

Glad to see that you got everything working so well.

The only problem I found is that when the rotation is set to 000 and I click on rotate then the program hangs. Eh, but it's not like someone would actually do that.

Nicely done!

umm, doesn't the rotation won't work at all?

PostPosted: Mon Aug 06, 2007 8:01 am
by summer_goth
:lol: sorry Game A Gogo, I assumed it was working because the little rotation buttons are working. I should learn to test properly before I reply.