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

Username:   Password: 
 RegisterRegister   
 New user, first prog
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
NikG




PostPosted: Wed Mar 15, 2006 4:08 pm   Post subject: New user, first prog

A warm hello to all,

(I couldn't find a section for new member introductions so I'm just going to do it here)

My name is Nik, I live in Toronto, and I program for fun. I just recently got interested in Turing again (after a 3-4 year break). I came across this site last week and I can honestly say it's great! So I figured that since I will probably be browsing this site a lot, I might as well join and maybe upload some of my projects...

Just a note, programming is simply a hobby for me, and I find I don't have much time for it (between 2 university courses, full-time work, a long-term realtionship, being an executive in a club...). So unfortunately, I may disappear for days/weeks at a time; please don't be offended by this.

Well enough of the introduction. Here's a little idea I started working on last week. It's a very simple attempt at a template for basketball-type games. My goal is to use this to create a 3 point shootout game, a HORSE-type game, & possibly a 1on1 game. I will probably put up the source code at a later time.

About 360 lines (minus 30 or so empty spaces) total so far, mostly because I'm adding many procedures so that it's flexible and I can use it as an engine for the actual games.

Controls: Arrow keys to move player, Space to shoot, Space to select power/accuracy, x to quit (when not in shooting mode)



BBall.zip
 Description:
BBall v0.4c
Arrow keys to move player
Space to enter shooting mode
Space to select power/accuracy
x to quit

Download
 Filename:  BBall.zip
 Filesize:  271.8 KB
 Downloaded:  208 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
jamonathin




PostPosted: Wed Mar 15, 2006 5:58 pm   Post subject: (No subject)

Welcome to the CompSci Forums Nik Smile.

Nice game i must say. I really like the power an accuracy bars, especially the accuracy, this way the game's not a piece of cake, (even though right now it's not too hard once you understand it).

Im guessing you're going to need a larger screen if the player is going to shoot from outside the 3 point line, either that or scale the bars more.

The game has much potential to it to grow from. Personally what I would do next is make the basketball more, ball-like. By this i mean:
- Bouncing off the backboard
- Rolling on the ground : friction
- Make the player go to the ball and pick it up

Like I said, there's much room to grow from this demo, and i hope to see bigger and better things from this. . . (AI included) . . Good Luck Smile.
TheOneTrueGod




PostPosted: Wed Mar 15, 2006 6:56 pm   Post subject: Reply

Aye, 'tis quite nicely done. I'm impressed by the lack of imported pictures, and yet it still looks good (i'm an avid anti-graphic person). One suggestion to try is to move the ball in three dimensions. Give the ball a Z co-ordinate, and draw the balls location at (x,y+z), and then draw an ovular shadow at the position of (x,y). Theres probably a way to calculate what the z speed would have to be in relation to the gravity and the Y speed, or you can just guess and check depending on how it was programmed.

excellent work
NikG




PostPosted: Wed Mar 15, 2006 11:32 pm   Post subject: (No subject)

Thanks for the comments guys.

jamonathin:
Do u think a bigger screen is necessary? Were you able to view the game properly? I ask because I've made the screen this small on purpose (what that purpose is still needs to be determined, haha).
Also, 3 point shooting does work (although it's worth 2 and inside the arc is worth 1), but I've made it so that you can only go a bit beyond the 3pt line b4 you don't have enough power to make the shot.
(Try going to the half way point between the arc and the lower rings in the middle of the screen. If you can hit max power and hit the accuracy, you will make the shot.)
The other things you mentioned (backboard bouncing, making the person rebound/pick up the ball) are in the plans.

TheOneTrueGod:
A very interesting suggestion with the shadow/z-coordinate. I hadn't even considered a 3d approach. However, I must admit that I'm lost as to how to implement gravity and such.
TheOneTrueGod




PostPosted: Thu Mar 16, 2006 12:33 am   Post subject: Gravity

code:

const grav := 0.3 %I've tested different values, and the one that i've
%Found to be the best is 0.3 (This is my pref. for all I know, you might like
%9.8, though that would be rediculously fast :P)

var x, y, z : real := 100 %The co-ordinates of the ball. (You gotta work
%with reals to get exact calculations)
z := 10 %Initialize the Z as different from the x and y
var xs, ys, zs : real := 0 %The speeds of the ball.
loop
    %Increment the co-ordinates by their respective speeds
    x += xs
    y += ys
    z += zs

    %Decrease Y speed by gravity
    ys -= grav

    %Make the ball bounce off the ground (Change the 1.2 to a higher
    %number to make the ball slow down quicker)
    if y <= 0 then
        y := 0
        ys := -ys / 1.2
    end if

    %Draw the ball and its shadow
    drawfilloval (round (x), round (y + z), 5, 5, brightred)
    drawfilloval (round (x), round (z), 5, 2, Rand.Int (0, 1) * black)

    Time.DelaySinceLast (30)
    cls
end loop


Theres an example of a ball bouncing in spot. It shows you the basics of how to get gravity working, as well as how to get the ball bouncing. You just need to have a variable that keeps track of the speed of the object.[/code]
jamonathin




PostPosted: Fri Mar 17, 2006 3:17 pm   Post subject: (No subject)

The only reason I suggested a larger screen was because it seemed that your power bar was calculated by the distance away from the basketball net, and if you got too far, more power would be necessary, whereas the powerbar cannot support that much.

I just suggested that because if you dont want to change the difficulty of hitting the correct power spot, you'll need to make the power bar larger to fit the distance, or just scale down the power bar (in turn making it harder to get the desired power)
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: