Computer Science Canada

Pure Slime Volleyball

Author:  Cervantes [ Sun Nov 28, 2004 10:53 am ]
Post subject:  Pure Slime Volleyball

Oh so long ago I tried oh so hard to make Slime Volleyball. Homer made the basis for me, then I continued. But the collisions were all wrong. After a while I discovered how I could use a repulsing gravity field for circular collision data. It worked well, and I polished the game up. Now, about half-a-year later, I've decided to post it.
The game is not by any means finished. There is a lot more that can be done with this in terms of gameplay, I'm sure, though I'm mostly out of ideas. If anyone has any ideas for gameplay, please share.
Perhaps in the future I will add a single player mode with AI.
The game is currently two-player only.

CONTROLS:
Player 1
Move Left : a
Move Right : d
Jump : w

Player 2
Move Left : Left Arrow
Move Right : Right Arrow
Jump : Up Arrow

You have three hits to get the ball to the other side. You have an unlimited number of hits on serves. You can only score points on your own serve.
Grab a friend and play to whatever you want, or, if you have incredible video game coordination, try playing against yourself. Wink
Press escape to exit.

Author:  cool dude [ Sun Nov 28, 2004 3:25 pm ]
Post subject: 

wow thats so cool. it's a copy of slime volleyball. i don't know if it's your code or my computer but the score is kinda screwed up and i couldn't exit your program until i pressed control alt delete. anyways very nice!

Author:  Cervantes [ Sun Nov 28, 2004 3:33 pm ]
Post subject: 

How's the score screwed up, specifically?
As for exitting, I decided on a whim to check the "Prevent user from exitting program" box, just because I don't like terminating the program in such a manner. That's why I said to press escape to exit Wink

Author:  zomg [ Sun Nov 28, 2004 3:38 pm ]
Post subject: 

works good just that u cant exit and thats very anoying

good job tho

Author:  Cervantes [ Sun Nov 28, 2004 3:44 pm ]
Post subject: 

So, pressing escape doesn't work? It works for me.

Author:  zomg [ Sun Nov 28, 2004 5:30 pm ]
Post subject: 

ok that works...

but usually people press the little x in the right hand corner

so u might want to enable that
just a suggestion tho

Author:  Cervantes [ Sun Nov 28, 2004 5:40 pm ]
Post subject: 

Well, it really doesn't matter, given that this is not the final copy, and I am more looking for suggestions on gameplay / any bugs.
If I ever finish this, it would have a menu and such with a quit option. And to quit in game, just press esc. Any full-screen games are usually exited by pressing esc or an F# button. That's kinda what that was like.
Anyways, suggestions anyone? The more radical the better! Smile

Author:  Neo [ Sun Nov 28, 2004 6:06 pm ]
Post subject: 

I can barley play it because the screen resolution is a bit too big. I can barely see the tip of the players head and if I scroll down to see the players it gets all distorted and the screen doesnt update right so there is streaks left all over. Perhaps you can add a resolutions option.

Author:  Cervantes [ Sun Nov 28, 2004 7:38 pm ]
Post subject: 

Good idea. I assume you're using 800x600?

I'm also wondering about speed: does it seem to run well on your computers? I opened this program yesterday for the first time in a few months and it was running very slowly. I can't remember changing anything, but when I opened it ran very slowly. So I switched the View.Update to a few View.UpdateAreas and it mostly returned to normal pace, as far as I could tell. If anyone experiences very slow game play, please let me know. Smile

Author:  zomg [ Sun Nov 28, 2004 8:40 pm ]
Post subject: 

i know slime volley ball is just shapes but do u think u could input pictures over that...

Author:  m&m [ Sun Nov 28, 2004 8:49 pm ]
Post subject: 

this is kewl man nice work Smile just like the real thing

Author:  Cervantes [ Sun Nov 28, 2004 8:54 pm ]
Post subject: 

I suppose I could. Though I was planning on having an option for adjusting the player's sizes, so as to give one player a handicap or make it more difficult for the other. Pic.Scale would do the trick, here.
The other thing about doing this is: what would the pictures look like? Would it be like the pictures they use here? I'm kinda against that, because one of the most unique things about my SV is that the slimes are full circles, not just semi-circles, allowing the players to spike the ball. I suppose the pictures could be full circles.
The final reservation I have against doing this is speed: would it be slower (in terms of the speed the program runs at) to, say, draw a preloaded picture, or to do a drawfilloval for his body and a drawfilloval for his eyes?

Author:  zomg [ Sun Nov 28, 2004 9:17 pm ]
Post subject: 

ya thats a good idea Smile that would be awesome if u made difficulty levels against the computer

Author:  Cervantes [ Sun Nov 28, 2004 9:41 pm ]
Post subject: 

Heh, that's the ultimate goal. Way back when I was working on this I figured out that, given two points, I could manipulate the quadratic formula to determine where the ball would land. I got it to work in a fresh program, though it was always off when I tried to add it into Pure SV. I guess when I start working on this again I'll try to sort that out.
For levels of difficulty, I was thinking to have a random and purposeful miscalculation of where the ball will land. Perhaps this a too simple way of doing the difficulty setting, though I think it's a pretty good idea given I've never made any AI before Wink.
I was also thinking that, at higher levels of difficulty, the computer could move back a little bit if the player has positioned himself close to the net, or to move forward a little bit if you are far away from the net. When I say move back and move forward, the middle that I am using is such that the ball would bounce off the slime in the same trajectory that it came in at.

Author:  Carino [ Sun Nov 28, 2004 11:04 pm ]
Post subject: 

Nice prog. It runs a little slow and i think you should make them half-circles because it looks weird when the other half of their body appears when they jump. Also, in the original SV you can spike the ball if you know what your doing, I learned this through many hours of play during com-tech. When the balls near your have to jump then push forward hitting the ball with the slimes front/nose area which will cause the ball to go down on an angle.

Author:  zomg [ Sun Nov 28, 2004 11:14 pm ]
Post subject: 

i dont find it slow what kind of computer u got

i got my athlon 64 yesterday for christmas (early but im happy) Smile

Author:  Carino [ Sun Nov 28, 2004 11:23 pm ]
Post subject: 

p3 866 Sad Don't laugh.. new ones comming.. one day.

Author:  Cervantes [ Mon Nov 29, 2004 3:50 pm ]
Post subject: 

hmm, I was hoping it would be fast enough to run on a p3. Is it consistantly slow, or do you find it slows down at some points (like when you hit the ball, or jump, etc.)

Carino wrote:

i think you should make them half-circles because it looks weird when the other half of their body appears when they jump. Also, in the original SV you can spike the ball if you know what your doing, I learned this through many hours of play during com-tech. When the balls near your have to jump then push forward hitting the ball with the slimes front/nose area which will cause the ball to go down on an angle.

I thought it looked wierd at first too, but now I think it looks fine. Also, as for spiking in the real SV, I've tried to before, and the best spike I can get is more hitting it off the nose of your guy so that it doesn't gain any upward velocity and moving back, such that it just drops. But with full circles, you are actually hitting it downwards. Unless you mean the top portion of the ball hits your guys nose, causing it to shoot downwards. Thinking That's an interesting idea. Perhaps, perhaps. But in the SV I don't remember that ever happening.

Author:  Carino [ Mon Nov 29, 2004 4:22 pm ]
Post subject: 

I find it slow through the whole game, like its all in slow-mo. The slimes seem to move too slowly in respect to the ball, i can never make it to the balls location in time. Also, in the original SV, you could hit the ball with your slimes nose and push forward causing it to go downward in the opposite direction. It was hard to do and ended up causing the player to lose points when attempting to do it, but it can be done.

Author:  Cervantes [ Mon Nov 29, 2004 4:35 pm ]
Post subject: 

It almost seemed as though the real SV just uses a bunch of if statements to determine where the ball is in relation to the player, then put a predefined speed and direction to the ball. I often found that you could hit the ball almost directly on top of you and the ball would shoot forwards, as opposed to going up.

I'll have to play around more with the program to find out what's causing it to go so slowly.

Author:  cool dude [ Mon Nov 29, 2004 7:09 pm ]
Post subject: 

i don't have a good computer but it works fine on my computer. the only thing is that sometimes i get a point and it doesn't add it to my score.

Author:  Cervantes [ Mon Nov 29, 2004 7:16 pm ]
Post subject: 

Woops, I probably should have added that into the first post: you can only score points on your own serve.
Would that explain what was happening for you, or was it something different?
btw, how fast is your computer? "good" can mean so many things these days, what with 3.0 + ghz computers (and even laptops, like Dan Rolling Eyes )

Author:  zomg [ Mon Nov 29, 2004 10:52 pm ]
Post subject: 

k that explains alot about the score...
i was about to post the same thing Laughing

Author:  cool dude [ Tue Nov 30, 2004 8:48 pm ]
Post subject: 

yeh thats wat the problem was. u should have also posted in your first post that to exit u got to hit escape key because i had to press contro alt delete. anyways nice program.

P.S. u should update it with new levels, and maybe add some sound to it.

Author:  Martin [ Wed Dec 01, 2004 3:20 am ]
Post subject: 

Looking good. Those circles are so...realistic!

You might want to slow down the ball a bit, it's kind of hard to chase.

For a nice improvement, make the sludge splash when the player jumps.

Author:  m&m [ Wed Dec 01, 2004 12:15 pm ]
Post subject: 

i think this program is awesome... just the ones online good job Very Happy

Author:  Cervantes [ Wed Dec 01, 2004 5:41 pm ]
Post subject: 

cool dude wrote:
yeh thats wat the problem was. u should have also posted in your first post that to exit u got to hit escape key because i had to press contro alt delete. anyways nice program.

P.S. u should update it with new levels, and maybe add some sound to it.

Heh, I did explain how to exit in the first post... when I posted it.
When you say new levels, do you mean make AI and have levels of increasing AI difficulty, or different colours for the background (like in the first SV), or do something funky with the levels. Hey! Speaking of funky, I wonder what it would be like if I put some 'bars' in the levels that the ball could bounce off. Maybe a horizontal bar a ways above the net, and maybe a diagonal bar at the back of the player's court to hit the ball off of so that it shoots down to the ground. I kinda wanted this game to be more offensive oriented than the other SV, which I find to be too much about defense and therefore boring.

martin wrote:

You might want to slow down the ball a bit, it's kind of hard to chase.

Is it a problem of the slimes moving too slow in relation to the ball, or the ball moves too fast for reaction time? Ie. are you saying I should increase the delay, or decrease the speed of the ball and the power of the slimes?

martin wrote:

For a nice improvement, make the sludge splash when the player jumps.

The sludge? Are you talking about the ground?

Thanks for the feedback everyone! Keep it coming Very Happy

Author:  zomg [ Wed Dec 01, 2004 6:23 pm ]
Post subject: 

i like the obstacle idea where theres stuff that the ball can hit other than the ground, the wall, and the slimes

Author:  Viper [ Thu Dec 02, 2004 1:33 pm ]
Post subject: 

i like the program but hate the game(prob. bc i suck at it lol)how many lines was this?

Author:  Cervantes [ Thu Dec 02, 2004 4:28 pm ]
Post subject: 

299, though I could probably reduce it to about 200 soon.

Author:  Neo [ Thu Dec 02, 2004 5:06 pm ]
Post subject: 

can u post the source so we can learn from it? or post some example code.

Author:  Cervantes [ Thu Dec 02, 2004 6:20 pm ]
Post subject: 

I posted it as a .exe because I may use this as my FP for next semester. I suppose I could post some example code, however. What would you like to see?

Author:  Carino [ Thu Dec 02, 2004 6:22 pm ]
Post subject: 

Collision detection!!! heh heh heh Twisted Evil

Author:  Cervantes [ Thu Dec 02, 2004 6:37 pm ]
Post subject: 

Already done.

code:

    %PLAYER 1
    if Math.Distance (player_1.x, player_1.y, ball.x, ball.y) < player_1.radius + ball.radius then
        if ~player_1.serving and player_1.ball_enter_player then
            player_1.hits_left -= 1
            player_1.ball_enter_player := false
        end if
        player_1.GFdist := Math.Distance (player_1.x, player_1.y, ball.x, ball.y)
        player_1.GFforce := player_1.GFstrength * (1 / player_1.GFdist * player_1.GFdist)
        if player_1.x = ball.x then
            player_1.GFangle := 0
        else
            player_1.GFangle := arctand ((player_1.x - ball.x) / (player_1.y - ball.y))
        end if
        if ball.y < player_1.y then
            player_1.GFangle += 180
        end if
        ball.vx += player_1.GFforce * sind (player_1.GFangle)
        ball.vy += player_1.GFforce * cosd (player_1.GFangle)
        player_2.hits_left := 3
        player_2.serving := false
    else
        player_1.ball_enter_player := true
    end if


That's just for player 1. Player 2 is the same, only reversed.
Sorry for the lack of comments. If you don't understand it, check out the tutorial. It should help. Wink
When I spoke about reducing the lines to around 200, I was referring to changing player_1 and player_2 into a player array consisting of 2 elements. Doing that would change this part.

Author:  MihaiG [ Thu Dec 02, 2004 8:50 pm ]
Post subject: 

nice job Geoff i would give you bits... but it wouldn't matter.... try and make it 1 player make computer AI

Author:  zomg [ Mon Dec 13, 2004 11:48 am ]
Post subject: 

u should have a 1 player mode and a 2 player mode

Author:  Cervantes [ Tue Dec 14, 2004 9:20 pm ]
Post subject: 

I'm working on determining where the ball will land. Click Me

Actually, it would ultimately be best to be able to determine where it will land using any two points, not just a point and the vertex of the parabola. Anyone know how to do this? Or fix the problems in the program linked?

Author:  Paul [ Tue Dec 14, 2004 9:47 pm ]
Post subject: 

What do u mean using any 2 points?
We have to do an projectile motion program, that involves using a formula to determine, which involves time, horizontal velocity and verticle velocity and gravity. The one I made increases the time by 0.01 each time, and plugs in the velocities, so it'd tell me the x and y coordinates. But I don't suppose such a simple thing is what ur looking for, for you'd have seen it already.

Author:  Cervantes [ Tue Dec 14, 2004 9:57 pm ]
Post subject: 

By any two points I mean:
In the program I posted, I used a point on the parabola (I assigned it immediately) and the vertex to determine where the ball will land. This, however, requires that the ball have reached the vertex before the computer slime can move into position. It would be best if I only needed two points on the parabola. ie. the first point is assigned immediately. The second point is assigned right after ball.x and ball.y have been updated once.

Sounds like an interesting program that you are making. Though I don't need to determine the horizontal velocity, verticle velocity, and gravity, because I already know those. I need to determine ahead of time where the ball is going to land so that I can move the computer slime into position to return the shot.

Author:  GlobeTrotter [ Tue Dec 14, 2004 11:22 pm ]
Post subject: 

say your two points were (1,1) and (2,2) and you know the final y value will be 0 as well as your starting y value, to find where it will end do this

a(x-h)2 + k = y

a(1-h)2 + 0 = 1
a(2-h)2 + 0 = 2

sub the equations together to solve for 'a' then 'h'. That should give you a full equation. You can then find the roots.

This is assuming that he starts the jump and lands the jump at y = 0, remember.

Also, if you only check one step after it is launched, you will get skewed results. You should check a couple steps after.

Author:  Cervantes [ Wed Dec 15, 2004 4:03 pm ]
Post subject: 

Why did you suddenly make k = 0? (k is the y vertex, right?)
GlobeTrotter wrote:
the final y value will be 0 as well as your starting y value

Well, the starting y is not necesasrily 0. The player can hit it in the air. Though this
GlobeTrotter wrote:

This is assuming that he starts the jump and lands the jump at y = 0, remember.

is correct.
(or I can make it correct, easily enough, by skewing the drawing parameters)

Author:  GlobeTrotter [ Wed Dec 15, 2004 6:07 pm ]
Post subject: 

oops, you're right, sorry.

I mixed up a circle and a quadratic, yeah. I guess you're going to have to do this then. You're 'a' value will be a constant based on your gravity and jump speed. Calculate that then plug that into the equation along with the other 2 points. That should work

(Say you calculated a to be -1 and your two points were 1,1 and 2,2)

a(x-h)2 + k = y

-(1-h)2 + k = 1
-(2-h)2 + k = 2

1 + (1-h)2 = 2 + (2-h)2

Then solve for h. Use this value to solve for k. Then solve for the roots of the equation, or if you want to get more complex. Say you have a wall with the equation x = -20 another wall with the equation x = 20 and another wall w/ equation y = 0, you could find the points of intersection of the quadratic with the line. You'll have to do an if statement before plugging it in though, otherwise you might get an error of a negative root if they don't intersect.

I haven't really looked at your code, and if you have different jump speeds based on how quickly you press the jump button, you'll have problems.

edit: shit, didn't realize you wanted where the ball would land, I was talking about players. That sucks, you'll have different a values. I'm not sure then, sorry.

Author:  hdef [ Mon Dec 20, 2004 6:22 pm ]
Post subject: 

runs smooth and fast on my comp... and its only an 800


: