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

Username:   Password: 
 RegisterRegister   
 Matrix Text Effect Game
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
fishtastic




PostPosted: Sun Jan 20, 2008 9:27 pm   Post subject: Matrix Text Effect Game

I somehow had the idea of making this,
I thought if the text flying down the screen were something like "OMGWTFLOL" the it will be really funny Shocked Shocked

Well, here goes another chunk of codes. Smile

Turing:

% made by fishtastic
% control: left and right arrow.
% have fun!

var map : array 1 .. maxrow, 1 .. maxcol of int
var col : array 1 .. 25 of int
var x := 40
var y := maxrow
var key : array char of boolean
var line := repeat (" ", 26)
var gameOver := false

loop
    put "Enter a Pointless Line. (25 characters or shorter)"
    put "The longer then line is, the harder the game is."
    put ""
    get line : *
    exit when length (line) <= 25
end loop

for i : 1 .. length (line)
    col (i) := RGB.AddColor (0, i * (0.69 / length (line)) + 0.3, 0)
end for

for i : 1 .. maxrow
    for j : 1 .. maxcol
        map (i, j) := 0
    end for
end for

View.Set ("offscreenonly")
colour (green)
colourback (black)

loop
    cls
    map (1, Rand.Int (1, maxcol)) := length (line)

    for decreasing i : maxrow .. 2
        for j : 1 .. maxcol
            map (i, j) := map (i - 1, j)
            map (i - 1, j) := map (i, j) - 1
        end for
    end for

    for i : 1 .. maxrow
        for j : 1 .. maxcol
            if map (i, j) > 0 then
                if 256 + length (line) - map (i, j) > maxcolor then
                    color (green)
                else
                    colour (256 + length (line) - map (i, j))
                end if
                put line (map (i, j)) ..
                if y = i and x = j then
                    gameOver := true
                end if
            else
                if i = y and j = x then
                    color (white)
                    put "@" ..
                else
                    put " " ..
                end if
            end if
        end for
    end for

    for i : 1 .. 25
        drawline (0, Rand.Int (0, maxy), maxx, Rand.Int (0, maxy), black)
    end for

    View.Update
    Input.KeyDown (key)
    if key (KEY_LEFT_ARROW) and x > 1 then
        x -= 1
    end if
    if key (KEY_RIGHT_ARROW) and x < 80 then
        x += 1
    end if

    exit when gameOver
end loop

put "GAME OVER"
View.Update
Sponsor
Sponsor
Sponsor
sponsor
LaZ3R




PostPosted: Tue Jan 22, 2008 2:41 pm   Post subject: RE:Matrix Text Effect Game

Nevermind, I see your comment at the top of the program. Still weird...
Gooie




PostPosted: Tue Jan 22, 2008 3:23 pm   Post subject: Re: Matrix Text Effect Game

I love it. Simple, efficient, and fun.
Sean




PostPosted: Tue Jan 22, 2008 3:38 pm   Post subject: Re: Matrix Text Effect Game

Interesting, although it did distract some kids in our class from their work the other day.
ericfourfour




PostPosted: Tue Jan 22, 2008 4:21 pm   Post subject: RE:Matrix Text Effect Game

Good job. The main loop could use some better organization. The way you have it is:

Draw
Think
Think/Draw
Draw
Flip Backbuffer
Get Input
Think

If you make it so there is only one draw and one think, it will increase readability. You might also consider putting in an FPS limiter (delay or Time.DelaySinceLast) so everyone runs the same program.
fishtastic




PostPosted: Tue Jan 22, 2008 8:34 pm   Post subject: Re: RE:Matrix Text Effect Game

Cool comments!! Cool Cool Cool Cool

Vilament @ Tue Jan 22, 2008 2:38 pm wrote:
Interesting, although it did distract some kids in our class from their work the other day.

Yes!! my evil plan is starting to work. i will complete screw them by uploading something even more distracting

Gooie @ Tue Jan 22, 2008 2:23 pm wrote:
I love it. Simple, efficient, and fun.

Thank you!

LaZ3R @ Tue Jan 22, 2008 1:41 pm wrote:
Nevermind, I see your comment at the top of the program. Still weird...

were you trying to say something?

ericfourfour @ Tue Jan 22, 2008 3:21 pm wrote:

If you make it so there is only one draw and one think, it will increase readability. You might also consider putting in an FPS limiter (delay or Time.DelaySinceLast) so everyone runs the same program.

Yes. I was putting codes in procedure at the beginning, then I put them in the main loop to shorten the code down.
The program I pretty short, but organizing will make it even easier to real.

I found turing slow at out putting on my computer even without delay. but DelaySinceLast will probably maintain FPS in faster Comps.

thanks for all comments Mr. Green
ericfourfour




PostPosted: Tue Jan 22, 2008 11:57 pm   Post subject: RE:Matrix Text Effect Game

I don't mean you should put all your code into procedures. That is not required right now. Just try to keep everything together. It's a lot easier to get all of the user input, then process it, and then render it.

In Turing, I try to organize my main loop like this:

Get Input (Input.KeyDown, Mouse.Where, hasch, getchar)
Think (process input, do calculations, check if the program should exit)
Render (clear the screen, draw everything)
Flip BackBuffer (View.Update)
FPS Limiter (Time.Delay or Time.DelaySinceLast)
Carey




PostPosted: Thu Jan 24, 2008 9:54 am   Post subject: RE:Matrix Text Effect Game

Same with me.I usually build the loop with procedures titled
code:

loop
  input
  exit when not calculate
  draw
  Time.DelaySinceLast
end loop

With the View.Update inside the draw procedure
Sponsor
Sponsor
Sponsor
sponsor
anna12345




PostPosted: Tue Apr 22, 2008 10:09 am   Post subject: RE:Matrix Text Effect Game

ur a genius)))
crysis




PostPosted: Tue Apr 22, 2008 8:25 pm   Post subject: RE:Matrix Text Effect Game

tis is awsome i really enjoyed it however if theres 2 many characters you get trapped.
syntax_error




PostPosted: Tue Apr 22, 2008 9:08 pm   Post subject: Re: RE:Matrix Text Effect Game

crysis @ Tue Apr 22, 2008 8:25 pm wrote:
tis is awsome i really enjoyed it however if theres 2 many characters you get trapped.


he states himself: char limit 25.
crysis




PostPosted: Wed Apr 23, 2008 8:06 am   Post subject: RE:Matrix Text Effect Game

wat do u mean char limit 25?
nastynika




PostPosted: Wed Apr 23, 2008 8:51 am   Post subject: Re: RE:Matrix Text Effect Game

crysis @ Wed Apr 23, 2008 8:06 am wrote:
wat do u mean char limit 25?

he means dont use anymore than 25 characters
nastynika




PostPosted: Wed Apr 23, 2008 8:52 am   Post subject: Re: Matrix Text Effect Game

nice game

btw you could try doing something to give u a score or a timer on how long u lasted
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  [ 14 Posts ]
Jump to:   


Style:  
Search: