Rotation Code isnt working

You must understand the Game Editor concepts, before post here.

Rotation Code isnt working

Postby Game A Gogo » Wed Aug 01, 2007 1:34 am

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.
Attachments
CW-Sprite Designer.zip
no stealling :D
(146.25 KiB) Downloaded 183 times
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby DocRabbit » Wed Aug 01, 2007 3:30 am

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.
Last edited by DocRabbit on Wed Aug 01, 2007 5:26 am, edited 1 time in total.
User avatar
DocRabbit
 
Posts: 114
Joined: Fri Oct 27, 2006 2:56 am
Score: 10 Give a positive score

Postby DocRabbit » Wed Aug 01, 2007 4:22 am

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.
User avatar
DocRabbit
 
Posts: 114
Joined: Fri Oct 27, 2006 2:56 am
Score: 10 Give a positive score

Postby Game A Gogo » Thu Aug 02, 2007 2:10 am

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%
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby DocRabbit » Thu Aug 02, 2007 3:51 am

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.
User avatar
DocRabbit
 
Posts: 114
Joined: Fri Oct 27, 2006 2:56 am
Score: 10 Give a positive score

Postby DocRabbit » Thu Aug 02, 2007 4:01 am

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
User avatar
DocRabbit
 
Posts: 114
Joined: Fri Oct 27, 2006 2:56 am
Score: 10 Give a positive score

Postby summer_goth » Thu Aug 02, 2007 6:50 am

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.
User avatar
summer_goth
 
Posts: 153
Joined: Fri Jun 22, 2007 8:07 am
Location: South Africa
Score: 5 Give a positive score

Postby summer_goth » Thu Aug 02, 2007 7:06 am

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.
User avatar
summer_goth
 
Posts: 153
Joined: Fri Jun 22, 2007 8:07 am
Location: South Africa
Score: 5 Give a positive score

Postby Game A Gogo » Fri Aug 03, 2007 3:00 am

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
Attachments
CW-Sprite Designer.zip
(377.07 KiB) Downloaded 170 times
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby summer_goth » Fri Aug 03, 2007 7:18 am

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!
User avatar
summer_goth
 
Posts: 153
Joined: Fri Jun 22, 2007 8:07 am
Location: South Africa
Score: 5 Give a positive score

Postby Game A Gogo » Sat Aug 04, 2007 12:07 am

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?
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby summer_goth » Mon Aug 06, 2007 8:01 am

: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.
User avatar
summer_goth
 
Posts: 153
Joined: Fri Jun 22, 2007 8:07 am
Location: South Africa
Score: 5 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron