Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Maxx and Maxy trouble...
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
lapo3399




PostPosted: Fri Jul 14, 2006 1:58 pm   Post subject: Maxx and Maxy trouble...

Hi,

I am attempting to draw circles (Draw.FillOval) in one of my programs, and, unfortunately, when I use an in-class function to assign "maxx div 2" and "maxy div 2" to an array with an enumerated type in that class, and then use the two values inside of Draw.FillOval as the x and y locations. Seeing nothing on the screen, I put in a put command to output the values that the program had recorded for the positions in the array, and got approximately 9000 and 16000 for x and y. These are much too large, and I am wondering whether maxx/maxy are dependent solely on the size of the area defined in View.Set, or whether calculations can increase the size of them based on range or domain of output.

The following is my assignment of maxx and maxy to the array:

code:

for i : 1 .. plannum
            if orbit (orbt (i)).orb_data (ord (orbit.orb.id)) = orbit (orbt (i)).orb_data (ord (orbit.orb.orbi)) then
                planet (plnt (i)).init_pos (maxx div 2, maxy div 2)
                centered := i %ignore this, it applies to a different part of code
            end if
end for


And the following is my Draw.FillOval
code:

proc draw
        var rad, posx, posy, col : int
        randint (col, 1, 10)
        for i : 1 .. plannum
            rad := round ((planet (plnt (i)).pl_data (ord (planet.pl.mass))) * 4)
            posx := round (planet (plnt (i)).pl_data (ord (planet.pl.posx)))
            posy := round (planet (plnt (i)).pl_data (ord (planet.pl.posy)))
            Draw.FillOval (posx, posy, rad, rad, col)
        end for
end draw


Any help would be appreciated,
lapo3399
Sponsor
Sponsor
Sponsor
sponsor
lapo3399




PostPosted: Fri Jul 14, 2006 2:00 pm   Post subject: (No subject)

I should probably show the way the values are assigned to array using init_pos too:

code:

proc init_pos (_posx, _posy : real)
        pl_res (ord (pl.posx)):= _posx
        pl_res (ord (pl.posy)):= _posy
        pl_data (ord (pl.posx)):= _posx * 50 %The values should be very small to begin with, the *50 should not increase them into the thousands...
        pl_data (ord (pl.posy)):= _posy * 50
end init_pos



Thanks!
Delos




PostPosted: Fri Jul 14, 2006 2:01 pm   Post subject: (No subject)

Can't say for sure if indeed you are using the enum type, but as a work-around for this, you could declare two MAXX and MAXY constants in your parent class that would be referencable (word?) later on. This would ensure that you wouldn't be getting the wrong values...
Though you might want to make them variables instead and initialize them in an 'initialize' function, thus ways you can have screens of different size and not only (eg.) 800x600.
lapo3399




PostPosted: Fri Jul 14, 2006 2:06 pm   Post subject: (No subject)

That make sense.

Thanks a lot for your help Very Happy .
Delos




PostPosted: Fri Jul 14, 2006 4:33 pm   Post subject: (No subject)

Nevertheless, this still is an intriguing problem. I'd like to explore it a little further - just to figure out what the hell Turing's doing this time Laughing. PM your code when you get a chance so I can run it and (hopefully) figure out what's going on.
You could also post it here, but not everyone likes to release code-in-progress, your choice really!
lapo3399




PostPosted: Fri Jul 14, 2006 7:19 pm   Post subject: (No subject)

Oh... it's not Turing's fault, I figured out that it was mine Embarassed

Your method works better anyway than fixing what was wrong, but it isn't necessary for you to look at it... Turing is working.... this time.... Laughing
[Gandalf]




PostPosted: Fri Jul 14, 2006 8:28 pm   Post subject: (No subject)

Ok, you pass init_pos() two values, maxx div 2 and maxy div 2. Those numbers would be default (on the 640x480 screen) be 320 and 240. When you multiply them by 50 in the init_pos() procedure, why don't you expect them to be in the thousands? 320*50 is 16000, as you output said, and as the drawing suggested (ie. 16000 way way off a 1024x800 monitor).
Slaivis




PostPosted: Fri Jul 14, 2006 9:53 pm   Post subject: (No subject)

Hm... I think what he wanted to do was "A * 50 := x"

In order to do that, he would have to write it as "A := x / 50".


I know I've made similar mistakes before.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: