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

Username:   Password: 
 RegisterRegister   
 Psuedo 3d
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
petree08




PostPosted: Tue Oct 31, 2006 2:32 pm   Post subject: Psuedo 3d

This program gives the illusion of 3d . kind of primative but it looks kinda cool

code:


const NUM_OF_SIDES := 3

const C := 120
const C2 := 2
const CB := 7
const C3 := 10


var X : array 1 .. NUM_OF_SIDES of int
var Y : array 1 .. NUM_OF_SIDES of int

var X2 : array 1 .. NUM_OF_SIDES of int
var Y2 : array 1 .. NUM_OF_SIDES of int

var DIS : int


var Dy : array 1 .. NUM_OF_SIDES of int
var Dx : array 1 .. NUM_OF_SIDES of int
var Xm, Ym, Click : int


var Length : real4
var SlopeX, SlopeY : int
setscreen ("graphics:max,max,nobuttonbar,offscreenonly")
for Index : 1 .. NUM_OF_SIDES
    randint (X (Index), 1, maxx)
    randint (Y (Index), 1, maxy)
    randint (DIS, 50, 150)
    X2 (Index) := X (Index) - DIS
    Y2 (Index) := Y (Index) - DIS

    loop
        randint (Dx (Index), -2, 2)
        exit when Dx (Index) not= 0
    end loop
    loop
        randint (Dy (Index), -2, 2)
        exit when Dy (Index) not= 0
    end loop
end for


colorback (CB)
loop
    cls
    for Index : 1 .. NUM_OF_SIDES
        X (Index) := X (Index) + Dx (Index)
        Y (Index) := Y (Index) + Dy (Index)
        X2 (Index) := X (Index) - DIS
        Y2 (Index) := Y (Index) - DIS





        if X (Index) > maxx or X (Index) < 1
                then
            Dx (Index) := - (Dx (Index))
        end if
        if Y (Index) > maxy or Y (Index) < 1
                then
            Dy (Index) := - (Dy (Index))
        end if
        drawpolygon (X, Y, NUM_OF_SIDES, C)
        drawpolygon (X2, Y2, NUM_OF_SIDES, C2)
        %drawfillpolygon (X2, Y, NUM_OF_SIDES, 10)
        drawline (X (Index), Y (Index), X2 (Index), Y2 (Index), C3)



        drawoval (X (Index), Y (Index), 10, 10, C2)
        drawoval (X2 (Index), Y2 (Index), 10, 10, C3)
    end for

    View.Update
end loop

Sponsor
Sponsor
Sponsor
sponsor
DemonZ




PostPosted: Wed Nov 01, 2006 9:19 pm   Post subject: (No subject)

ill say not bad, pretty good for the illusion, it looks like its 3d, good job
Voltage128




PostPosted: Sat Dec 02, 2006 10:20 pm   Post subject: (No subject)

very cool illusion of it being 3d. You could try to make it look like the balls bounce off the walls better tho. On the top and right wall it does this well. But on the bottom and left wall it goes past the screen on mine. Other then that good job.
Silent Avenger




PostPosted: Sat Dec 02, 2006 10:57 pm   Post subject: (No subject)

Good job on creating the illusion, nice work.
Clayton




PostPosted: Sun Dec 03, 2006 4:34 pm   Post subject: (No subject)

code:

var X : array 1 .. NUM_OF_SIDES of int
var Y : array 1 .. NUM_OF_SIDES of int
var X2 : array 1 .. NUM_OF_SIDES of int
var Y2 : array 1 .. NUM_OF_SIDES of int
var Dy : array 1 .. NUM_OF_SIDES of int
var Dx : array 1 .. NUM_OF_SIDES of int


This could easily all become a type of its own (via records), check the Turing Walkthrough out for the tutorial on records and types. However, a quick example:

code:

const NUM_OF_SIDES := 3

type co_ords :
    record
        x, y, x2, y2, dx, dy : array 1 .. NUM_OF_SIDES of int
    end record

var shape : co_ords


Very Happy
[Gandalf]




PostPosted: Sun Dec 03, 2006 11:56 pm   Post subject: (No subject)

Or better yet:
code:
const NUM_OF_SIDES := 3

var shape : array 1 .. NUM_OF_SIDES of
    record
        x1, y1, x2, y2, dx, dy : int
    end record


Judging from your code, you should also take a look at the Turing Style Guidelines.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: