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

Username:   Password: 
 RegisterRegister   
 help soon plz
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
bluedevils_77




PostPosted: Thu Apr 20, 2006 4:17 pm   Post subject: help soon plz

im doing a solar system, thing for my grade 11 animation. If suppoused to show the planets moving around the sun, then quickly doom into earth. How can i make the middle point of earth be the middle point of the window,. Also the window is set to 1500, 1000 for the solar system, how can i make it smaller, without doing anohter View.Set. cuz view.set amkes it close the window and bring up a new one.

my code is:

View.Set ("graphics:1500,1400;offscreenonly")
var t, r,sec,d,u,n,m,rad,rad1 : int
var ang, ang1, ang2, ang3, ang4, ang5 : real
var x, y, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5 : real
var star : int

rad1:= 29
n:= 700
m:= 1000
d:= maxx div 2
u:= 1000
ang := 0
ang1 := 47
ang2 := 234
ang3 := 250
ang4 := 100
ang5 := 176
sec:= 0
colorback (7)
cls
%star---=========
for i : 1 .. 300
t := Rand.Int (0, maxx)
r := Rand.Int (0, maxy)
Draw.FillOval (t, r, 1, 1, 14)
end for
%sun===============================================================
Draw.FillOval (maxx div 2, maxy div 2, 70, 70, 42)
loop
%mercury=========================================================================
Draw.FillOval(d, u, 1, 1, 14)
Draw.FillOval(n,m,1,1,14)
x := (maxx div 2) + 103 * cosd (ang)
y := (maxy div 2) + 103 * sind (ang)
Draw.Oval (maxx div 2, maxy div 2, 103, 103, 56)
Draw.FillOval (round (x), round (y), 17, 17, white)
ang := ang + 5.6
delay (20)
%venus=======================================================================
x1 := (maxx div 2) + 160 * cosd (ang1)
y1 := (maxy div 2) + 160 * sind (ang1)
Draw.Oval (maxx div 2, maxy div 2, 160, 160, 56)
Draw.FillOval (round (x1), round (y1), 23, 23, 12)
ang1 := ang1 + 4.5
delay (20)
%earth===================================================================
x2 := (maxx div 2) + 240 * cosd (ang2)
y2 := (maxy div 2) + 240 * sind (ang2)
Draw.Oval (maxx div 2, maxy div 2, 240, 240, 56)
Draw.FillOval (round (x2), round (y2), 29, 29, blue)
ang2 := ang2 + 3.4
delay (20)
%mars==============================================================
x3 := (maxx div 2) + 320 * cosd (ang3)
y3 := (maxy div 2) + 320 * sind (ang3)
Draw.Oval (maxx div 2, maxy div 2, 320, 320, 56)
Draw.FillOval (round (x3), round (y3), 24, 24, brown) %need new brown!!
ang3 := ang3 + 2.8
delay (20)
%Jupiter
x4 := (maxx div 2) + 480 * cosd (ang4)
y4 := (maxy div 2) + 480 * sind (ang4)
Draw.Oval (maxx div 2, maxy div 2, 480, 480, 56)
Draw.FillOval (round (x4), round (y4), 38, 38, 162)
Draw.ThickLine (round (x4) - 42, round (y4), round (x4) + 42, round (y4), 2,white)
ang4 := ang4 + 2.2
delay (20)
%Saturn
x5 := (maxx div 2) + 630 * cosd (ang5)
y5 := (maxy div 2) + 630 * sind (ang5)
Draw.Oval (maxx div 2, maxy div 2, 630, 630, 56)
Draw.FillOval (round (x5), round (y5), 35, 35, 61)
Draw.ThickLine (round (x5) - 40, round (y5), round (x5) + 40, round (y5), 4,11)
ang5 := ang5 + 2.2
delay (20)
View.Update
Draw.FillOval (round (x2), round (y2), 29, 29, black)
Draw.Oval (maxx div 2, maxy div 2, 240, 240, 56)
exit when sec = 50
%redarwing
Draw.FillOval (round (x3), round (y3), 24, 24, black)
Draw.FillOval (round (x), round (y), 17, 17, black)
Draw.FillOval (round (x1), round (y1), 23, 23, black)
Draw.FillOval (round (x4), round (y4), 38, 38, black)
Draw.ThickLine (round (x4) - 42, round (y4), round (x4) + 42, round (y4), 4,
black)
Draw.FillOval (round (x5), round (y5), 35, 35, black)
Draw.ThickLine (round (x5) - 40, round (y5), round (x5) + 40, round (y5), 4,
black)
Draw.FillOval(d, u, 1, 1, 7)
%shoting star
d:= d- 9
u:= u - 3
delay(10)
%time to watch planets111
%shoting star
sec:= sec + 1
if sec = 30 then
n:=n - 7
m:=m -3
end if
end loop
Sponsor
Sponsor
Sponsor
sponsor
TokenHerbz




PostPosted: Thu Apr 20, 2006 4:31 pm   Post subject: (No subject)

ok 2 things 1st,

1) Use proper "help" titles when posting. Plz help soon is not pleasent.

2) When posting code, use CODE tags...

You would be lucky if you post isn't deleted, but i will post again with some help for you, if i can... Give me a few minuates.
Clayton




PostPosted: Thu Apr 20, 2006 4:38 pm   Post subject: (No subject)

i dont think you can actually resize the window without closing it the re-opening it. also, look into arrays, as they will help make your code neater, as you are new here i will suggest you to go to the Turing Walkthrough, where you can look through just about anything in turing, to make the earth the center of your screen (im assuming its just a circle) do something like this
code:

var x,y:int:=0
const RADIUS:int:=10

Draw.FillOval(maxx div 2,maxy div 2,RADIUS,RADIUS,black)

what ive done is drawn a circle with its center coordinates at half of the maximum x and half of the maximum y, with a radius of 10 pixels in the color black good luck i hope this helped
bluedevils_77




PostPosted: Thu Apr 20, 2006 4:43 pm   Post subject: (No subject)

we dunt learn arrays for another couple weeks...
Clayton




PostPosted: Thu Apr 20, 2006 4:48 pm   Post subject: (No subject)

check out the Turing Walkthrough (as mentioned above) as it takes you right through turing, and if you stick with it you will be miles ahead of your compsci class
HellblazerX




PostPosted: Thu Apr 20, 2006 4:51 pm   Post subject: (No subject)

i think wut you're asking for is how to have the window follow the earth as it does its orbit. In that case, you'll need do some scrolling. Basically, when you're drawing the planets and stuff, you'll need to draw them in according to their position from the earth.

Let's say for, example, your earth is at position (100,100), and Mars was at (200,200). To draw Mars, you would need to find its position relative to the earth. So, if the earth is to be drawn in the middle, (maxx div 2, maxy div 2), then Mars should be drawn at (200 - 100 + maxx div 2, 200 - 100 + maxy div 2).
bluedevils_77




PostPosted: Thu Apr 20, 2006 5:01 pm   Post subject: (No subject)

ive set it up so for, so when it exits the loop so when the planets stop in the program,all the planets should move over til earth is in the middle. My teacher said an easy way to zoom into earth, is just make it bigger, but the window is so big, u still see everything ebhind. cuz i dunt want to make earth totally gagantic
TokenHerbz




PostPosted: Thu Apr 20, 2006 5:02 pm   Post subject: (No subject)

thats incorrect superfreak, as his sun is is the center, and he wants the map centered on earth which is rotating around the sun...

To do this i think you need to modify your code something wicked.

Here is a little idea to help you, because i dont want to mess with your code...


Ex1: Useing the mouse:
code:

setscreen ("Graphics:max;max,offscreenonly")
View.Set ("offscreenonly")

var mapx, mapy : int := 0   %%chords of map
var Scroll_Rate : int := 5  %%how fast your map moves
var x, y, b : int   %%mouse chords (for this example

proc draw_map (mapx, mapy : int)
    drawfillbox (maxx div 2 + mapx, maxy div 2 + mapy, maxx div 2 + 50 + mapx, maxy div 2 + 100 + mapy, black)
end draw_map

loop
    cls

    Mouse.Where (x, y, b)
    if y >= maxy - 40 then     %%moves map up with mouse
        mapy -= Scroll_Rate
        draw_map (mapx, mapy)
    elsif y <= 40 then         %%moves map down with mosue
        mapy += Scroll_Rate
        draw_map (mapx, mapy)
    end if
    if x >= maxx - 40 then     %%moves map right with mouse
        mapx -= Scroll_Rate
        draw_map (mapx, mapy)
    elsif x <= 40 then         %%moves map left with mouse
        mapx += Scroll_Rate
        draw_map (mapx, mapy)
    end if

    draw_map (mapx, mapy)

    View.Update
    delay (20)
end loop


Now this way isn't really moving the screen to where you want, but moving the pics to make the screen appear where you want... I havn't done anything resembling keeping the screen matched with your pics which are moving... But if all else fails, you can try somthing along the my lines :S
Sponsor
Sponsor
Sponsor
sponsor
HellblazerX




PostPosted: Thu Apr 20, 2006 5:30 pm   Post subject: (No subject)

wouldn't that lag up the computer though, because you're essentially drawing the image, and then moving it around so the earth is in the center. Since he's using coordinates to draw the planets to begin with, why not play around with those values, so when he draws the planets, they'll be drawn so the earth is in the center.

An example for this would be:

code:
var ex, ey, mx, my, sx, sy : int
var msx, msy, ssx, ssy : int
var angEarth, angMars : int

View.Set ("graphics:max,max;offscreenonly")
sx := 500
sy := 500
angEarth := 180
angMars := 90
loop
    ex := round (sx + (240 * cosd (angEarth)))
    ey := round (sy + (240 * sind (angEarth)))
    mx := round (sx + (320 * cosd (angMars)))
    my := round (sy + (320 * sind (angMars)))
   
    msx := mx  + (maxx div 2 - ex)
    msy := my  + (maxy div 2 - ey)
    ssx := sx + (maxx div 2 - ex)
    ssy := sy + (maxy div 2 - ey)
   
    drawfilloval (maxx div 2, maxy div 2, 20, 20, green)
    drawfilloval (msx, msy, 20, 20, red)
    drawfilloval (ssx, ssy, 100, 100, yellow)
    %drawfilloval (ex, ey, 20, 20, green)
    %drawfilloval (mx, my, 20, 20, red)
    %drawfilloval (sx, sy, 100, 100, yellow)
   
    angEarth += 3
    angMars += 3
    View.Update
    delay (100)
    cls
end loop
TokenHerbz




PostPosted: Thu Apr 20, 2006 5:41 pm   Post subject: (No subject)

hellblazer, do you know how the cls / delay / View.updates work???

try this:::

after "loop" put cls, then update and delay
code:

loop
    cls 
    %%%%CODES%%%%
    View.Update
    delay(20)
end loop


That helps your code a GREAT deal... know why?
TokenHerbz




PostPosted: Thu Apr 20, 2006 6:22 pm   Post subject: (No subject)

you know after thinking about it your way should work to, i think maybe its your delay being to big...
HellblazerX




PostPosted: Thu Apr 20, 2006 7:29 pm   Post subject: (No subject)

ya that delay was big, mainly because I found i got dizzy from looking at the thing if the delay was like 20 or something.
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  [ 12 Posts ]
Jump to:   


Style:  
Search: