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

Username:   Password: 
 RegisterRegister   
 setscreen (maintain aspect ratio)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Sausage49




PostPosted: Wed Dec 21, 2016 8:00 pm   Post subject: setscreen (maintain aspect ratio)

For my computer science class we are required to make simple pixel animations. I want to lock the aspect ratio to 16:9 while keeping a scale able image for screen size.


I've attached the code below. The general idea is that if maxx or maxy is greater then the set resolution it jumps down to the next 16:9 resolution. For some reason this doesn't run. Am i making an error or is turing just not capable of doing this?



Turing:


loop
    if maxx < 3845 or maxy < 2165 then
        setscreen ("Graphics:3840;2160")
    else
        exit
    end if
    if maxx < 3840 or maxy < 2160 then
        setscreen ("Graphics:2560;1440")
    else
        exit
    end if
    if maxx < 2560 or maxy < 1440 then
        setscreen ("Graphics:1920;1080")
    else
        exit
    end if
    if maxx < 1920 or maxy < 1080 then
        setscreen ("Graphics:1600;900")
    else
        exit
    end if
    if maxx < 1600 or maxy < 900 then
        setscreen ("Graphics:1280;720")
    else
        exit
    end if
    if maxx < 1280 or maxy < 720 then
        setscreen ("Graphics:852;480")
    else
        exit
    end if
end loop




Im using Open turing 4.1.2
Sponsor
Sponsor
Sponsor
sponsor
Sausage49




PostPosted: Wed Dec 21, 2016 10:20 pm   Post subject: Re: setscreen (maintain aspect ratio)

Just realised i don't need it in a loop. New code as follows:

if maxx > 2560 or maxy > 1440 then
setscreen ("Graphics:3840;2160")
elsif maxx > 1920 or maxy > 1080 then
setscreen ("Graphics:2560;1440")
elsif maxx > 1600 or maxy > 900 then
setscreen ("Graphics:1920;1080")
elsif maxx > 1280 or maxy > 720 then
setscreen ("Graphics:1600;900")
elsif maxx > 852 or maxy > 480 then
setscreen ("Graphics:1280;720")
elsif maxx > 1280 or maxy > 720 then
setscreen ("Graphics:852;480")
end if





For some reason this results in defaulting to the last resolution int the list almost like its disregarding the if statements.
Sausage49




PostPosted: Wed Dec 21, 2016 11:46 pm   Post subject: Re: setscreen (maintain aspect ratio)

I have run into another sort of problem, however i dont feel it needs it's own topic so here it is:

I tried using the offscreenonly command to decrease flickering however it is still extremely present. Am i doing something wrong?

Code in question:

for count : 1.. maxy div 3
Draw.Cls
drawfillbox (maxx div 2, maxy div 3 + count, maxx div 1.6, maxy div 1.4, 90)
drawface
drawfillbox (maxx div 2, maxy div 3 + count, maxx div 1.6, maxy div 1.4, 90)
View.Update
delay (5)

end for

If context on the procedure is required ive attached the program



Assig10 (1).t
 Description:

Download
 Filename:  Assig10 (1).t
 Filesize:  2.88 KB
 Downloaded:  138 Time(s)

Insectoid




PostPosted: Thu Dec 22, 2016 5:25 pm   Post subject: RE:setscreen (maintain aspect ratio)

What is the default size of the run window? What will your if statement return given that resolution? Also, there's a typo in the last two resolutions in the if statement.

As for your flickering- the more often you call View.Update, the more flickering you'll get. You've got one in your drawface procedure that's probably causing problems. That procedure also has a cls in it, which is pretty silly because later in your code you draw stuff, then call drawface, which immediately erases everything you just drew!

You should have only one View.Update in your main loop. No function should call it. Your drawing functions should only ever draw as well- they shouldn't cls and they certainly shouldn't View.Update. The only spot you should use View.Update is immediately before the delay in your main loop.
Sausage49




PostPosted: Thu Dec 22, 2016 10:38 pm   Post subject: Re: RE:setscreen (maintain aspect ratio)

Insectoid @ Thu Dec 22, 2016 5:25 pm wrote:
What is the default size of the run window? What will your if statement return given that resolution? Also, there's a typo in the last two resolutions in the if statement.

As for your flickering- the more often you call View.Update, the more flickering you'll get. You've got one in your drawface procedure that's probably causing problems. That procedure also has a cls in it, which is pretty silly because later in your code you draw stuff, then call drawface, which immediately erases everything you just drew!

You should have only one View.Update in your main loop. No function should call it. Your drawing functions should only ever draw as well- they shouldn't cls and they certainly shouldn't View.Update. The only spot you should use View.Update is immediately before the delay in your main loop.


Awesome thanks for the advice for the View.Update.

As a side not i was looking through all the admins on the website and it seems like you are the only active one. What happened to the rest of them, most of them haven't posted in a few years.
Insectoid




PostPosted: Fri Dec 23, 2016 12:29 pm   Post subject: RE:setscreen (maintain aspect ratio)

Moderating & tutoring takes up quite a bit of time that the other admins/mods don't have anymore. The site needs someone to be the resident Turing expert, and I'm more than happy to help.
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  [ 6 Posts ]
Jump to:   


Style:  
Search: