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

Username:   Password: 
 RegisterRegister   
 little game of chance
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
apomb




PostPosted: Fri Feb 27, 2004 10:34 am   Post subject: little game of chance

This is probly the most primitive and non-good looking game ever, but i was just playing around with different speeds and angles when the ball bounces off the wall... just for fun!
code:
  %Adrian Pomber
% The "wallgame" program.
View.Set ("graphics, nooffscreenonly")
var x : int
var y : int
var speed, speed2 : int
var top, left, bottom, right : int := 0
put "Set initial speed: "..
get speed
speed2 := speed+2
put "Enter starting position: "
put "x: " ..
get x
put "y: " ..
get y
loop
    exit when x >maxx or x <=0 and y <0
    delay (10)
    cls
    Draw.FillOval (x, y, 10, 10, black)
    x += speed
    y += speed2
    if (x) <= 0 then
        speed := -speed - Rand.Int (1, 5)
        left += 1
    end if
    if (x) >= maxx - 10 then
        speed := -speed - Rand.Int (1, 5)
        right += 1
    end if
    if (y) <= 0 then
        speed2 := -speed2 - Rand.Int (1, 5)
        bottom += 1
    end if
    if (y) >= maxy - 10 then
        speed2 := -speed2 - Rand.Int (1, 5)
        top += 1
    end if
end loop
cls
put "You hit the top wall ", top, " times"
put "You hit the bottom wall ", bottom, " times"
put "You hit the left wall ", left, " times"
put "You hit the right wall ", right, " times"
if top >= 1 and bottom >= 1 and right >= 1 and left >= 1 then
    put "You hit all walls!!"
end if
Sponsor
Sponsor
Sponsor
sponsor
shorthair




PostPosted: Fri Feb 27, 2004 3:31 pm   Post subject: (No subject)

nice and fun , i had to imrove it before i played it to make it cooler, but your made a very entertaining game
Paul




PostPosted: Fri Feb 27, 2004 5:15 pm   Post subject: (No subject)

Is it just me, or does it speed up? Oh and it hit the bottom wall and went thru, and disappeared. Then It said I hit the bottom wall 450 times.
Cervantes




PostPosted: Fri Feb 27, 2004 5:44 pm   Post subject: (No subject)

Yes I'm getting the same problem with the bottom wall. Hit it 538 times Razz

is that supposed to happen? Where is the game aspect? Thinking
shorthair




PostPosted: Fri Feb 27, 2004 5:46 pm   Post subject: (No subject)

hence , the " i had to change some thing to make it cooler , "
apomb




PostPosted: Fri Feb 27, 2004 6:59 pm   Post subject: (No subject)

well i just sorta threw it together last night and thought it would be entertaining for poeple to do ... and improve if you wanted.
Paul




PostPosted: Fri Feb 27, 2004 10:33 pm   Post subject: (No subject)

I'd give you bits if you can make a flower or something popup wherever it hits on the wall.
the_short1




PostPosted: Sat Feb 28, 2004 12:24 am   Post subject: (No subject)

good job there compwizz... good for a one nighter.... (i made my rock paper scissors in like 2 days... cuz some guy was playing that with his hands in my comp sci class...)....

here i added a impact identifier...


....yea... point cervantes.... someone above asked for one with an impact identifier... so i did it for compwizz



wallzzzz.t
 Description:

Download
 Filename:  wallzzzz.t
 Filesize:  1.33 KB
 Downloaded:  284 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sat Feb 28, 2004 11:43 am   Post subject: (No subject)

um, how's that better than what he had? all you did is draw a huge oval when it hits the wall and add a small delay...
apomb




PostPosted: Sat Feb 28, 2004 3:20 pm   Post subject: (No subject)

Well , is this one better? ... theres no cls ... it shows you where you hit the wall with a STAR.
code:
%Adrian Pomber
% The "wallgame" program.
View.Set ("graphics, nooffscreenonly")
var x, y, j, k, i, h, q, w, r, e, t, u, z, b, n, m, s, d : int := 0
var speed, speed2 : int
var top, left, bottom, right : int := 0
colorback (black)
cls
color (white)
Text.Locate (10, 32)
put "Set initial speed: " ..
get speed
speed2 := speed + 2
Text.Locate (11, 32)
put "Enter starting position: "
Text.Locate (12, 32)
put "x: " ..
get x
Text.Locate (13, 32)
put "y: " ..
get y
loop
    exit when top > 2 or bottom > 2 or right > 2 or left > 2 or (top >= 1 and bottom >= 1 and right >= 1 and left >= 1)
    Draw.FillOval (x, y, 10, 10, 42)
    drawfillstar (j, h, k, i, yellow)
    drawfillstar (q, w, r, e, yellow)
    drawfillstar (t, u, z, b, yellow)
    drawfillstar (s, d, n, m, yellow)
    View.Update
    delay (10)
    View.Update
    cls
    x += speed
    y += speed2
    if (x) <= 0 then
        speed := -speed - Rand.Int (1, 5)
        left += 1
        j := x - 20
        h := y - 20
        k := x + 20
        i := y + 20
        drawfillstar (j, h, k, i, yellow)
        sound (1000, 50)
    end if
    if (x) >= maxx - 10 then
        speed := -speed - Rand.Int (1, 5)
        right += 1
        q := x - 20
        w := y - 20
        r := x + 20
        e := y + 20
        drawfillstar (q, w, r, e, yellow)
        sound (1000, 50)
    end if
    if (y) <= 0 then
        speed2 := -speed2 - Rand.Int (1, 5)
        bottom += 1
        t := x - 20
        u := y - 20
        z := x + 20
        b := y + 20
        drawfillstar (t, u, z, b, yellow)
        sound (1000, 50)
    end if
    if (y) >= maxy - 10 then
        speed2 := -speed2 - Rand.Int (1, 5)
        top += 1
        s := x - 20
        d := y - 20
        n := x + 20
        m := y + 20
        drawfillstar (s, d, n, m, yellow)
        sound (1000, 50)
    end if
end loop
cls
put "You hit the top wall ", top, " times"
put "You hit the bottom wall ", bottom, " times"
put "You hit the left wall ", left, " times"
put "You hit the right wall ", right, " times"
if top >= 1 and bottom >= 1 and right >= 1 and left >= 1 then
    delay (1000)
    cls
    colorback (black)
    cls
    color (white)
    Text.Locate (10, 32)
    put "You hit all the walls!!" ..
end if
programer007




PostPosted: Sun Mar 07, 2004 5:51 pm   Post subject: (No subject)

thats a cool program... it reminds me of 'Bounce' program from book, only that one was for text...this is graphics... here +2 bits..
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  [ 11 Posts ]
Jump to:   


Style:  
Search: