oneslime.net Forum Index oneslime.net
Slime talk
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

new slime thing (hopefully)

 
Post new topic   Reply to topic    oneslime.net Forum Index -> Programming
View previous topic :: View next topic  
Author Message
foolnthehill
Pathetic White Slime


Joined: 01 Dec 2006
Posts: 24
Location: under your bed

PostPosted: Sat Dec 02, 2006 5:31 pm    Post subject: new slime thing (hopefully) Reply with quote

Well, I started to teach myself Java stuff a little while back and have gotten to the point where I can do things badly Very Happy ! I wanted to make a little slime volleyball g.ame of some sort (here's what I have so far). You'll probably have to click on the applet 4 or more times to get keyboard focus. To see the source, just change ".html" to ".java".
As you can see, I've kind of made up my own methods for doing things, such as using threads in stupid ways. Most of my programming experience has come from BASIC on TI graphing calculators Laughing . My real problem, though, is getting all the physics(s?) to work right. Specifically, I can't think of a good way to add the slime's velocity to that of the ball. There might be another thing keeping it from working right, but that's the main thing.
It's strange: I've been making the whole thing on Mac OS X Tiger. On my computer, it runs fine. But, on Windows computers, the whole applet seems to freeze after the ball first comes down onto the slime.
So... can anyone help me out? If you save my life, I'm eternally grateful.


Last edited by foolnthehill on Tue Dec 05, 2006 3:12 pm; edited 1 time in total
Back to top
View user's profile Send private message
JavaWiz
Inferior Human Controlled Slime


Joined: 27 Nov 2006
Posts: 8

PostPosted: Tue Dec 05, 2006 9:16 am    Post subject: Reply with quote

Whoa man! nice! Can you teach or make me some tutorials of java, i really want to lear. really, really, really badly, so please, if you have any fre time of your own, teach me some basic java perhaps?
Back to top
View user's profile Send private message
foolnthehill
Pathetic White Slime


Joined: 01 Dec 2006
Posts: 24
Location: under your bed

PostPosted: Wed Dec 06, 2006 12:41 pm    Post subject: Reply with quote

You'd probably be better asking someone like wedgey; he knows much more of the Javian ways. I'm not too bad (or good), but I tend to go about doing things in my own way. That's only a disadvantage if you intend to work with other people's code and things.
If you don't mind that, though, I can probably put something together over Christmas break or something (a high school junior I am).
Back to top
View user's profile Send private message
wedgey
Site Admin


Joined: 01 Mar 2006
Posts: 207
Location: three quarters of a mile from the surface of the sun

PostPosted: Wed Dec 06, 2006 1:02 pm    Post subject: Reply with quote

Cool, looks good! btw it doesn't seem to freeze in Firefox in Windows for me.

This is taken from the 2 player Slime Volleyball code you can download from http://oneslime.net/two/Slime2P.java (you can get it from other places but this version is slightly easier to read).

I forget how this works with determining the ball's velocity after the collision (maybe Kypzethdurron can decipher it for us!) but this is what's in the MoveBall() method:

Code:

        // collision detection
        if(!fEndGame) {
            int dx = 2*(ballX-p1X);
            int dy = ballY-p1Y;
            int dist = (int)Math.sqrt(dx*dx+dy*dy);
            int dvx = ballVX-p1XV;
            int dvy = ballVY-p1YV;
            if(dy > 0 && dist < p1Diam+ballRad && dist > fudge) {
                /* i have nfi what this is. i'm supposed to have done engineering
                dynamics and i can't remember any equation with x*x'+y*y' in it...
                it was a long time ago! - wedgey */
                int something = (dx*dvx+dy*dvy)/dist;
                ballX = p1X+(p1Diam+ballRad)/2*dx/dist;
                ballY = p1Y+(p1Diam+ballRad)*dy/dist;
                // cap the velocity
                if(something <= 0) {
                    ballVX += p1XV-2*dx*something/dist;
                    if(ballVX < -maxXV)
                        ballVX = -maxXV;
                    if(ballVX > maxXV)
                        ballVX = maxXV;
                    ballVY += p1YV-2*dy*something/dist;
                    if(ballVY < -maxYV)
                        ballVY = -maxYV;
                    if(ballVY > maxYV)
                        ballVY = maxYV;
                }
                fP1Touched = true;            
            }


@JavaWiz:
I actually started doing a set of tutorials before I lost time and motivation and then later decided to do that tennis game instead Razz But they're not exactly introductory tutorials... maybe a good place to start is http://java.sun.com/docs/books/tutorial/. Then, once you know the basics, you can head over to http://oneslime.net/wiki/Category:Tutorials to see how to make some simple animations (which leads to games).
Back to top
View user's profile Send private message
JavaWiz
Inferior Human Controlled Slime


Joined: 27 Nov 2006
Posts: 8

PostPosted: Wed Dec 06, 2006 1:08 pm    Post subject: Reply with quote

Cool thanks Wedgey. I appreciate this. And thanks foolinthehill, if you can put something together over christmas. Smile, i tried that java tutorial page you gave me, and im sorry, but i got really really lost. I think i need to approach the java programming language in an easier way. this is much MUCH MUCH harder then Pascal. I already took a few classes in Pascal, which i guess im pretty good at, but Java is really confusing me. May you put a little tutorial in a word document or something, on maybe a program, to add 2 integers? thanks. Smile
Back to top
View user's profile Send private message
foolnthehill
Pathetic White Slime


Joined: 01 Dec 2006
Posts: 24
Location: under your bed

PostPosted: Thu Dec 07, 2006 12:19 pm    Post subject: Reply with quote

Wow. That's exactly what I needed, wedgey. Thank!s Just one question: Do you know what "fudge" is for? Correct me if I'm wrong, but I'm thinking it's to prevent the yielding of inaccurate results when the distance between the center of the slime and the ball is too small.
Back to top
View user's profile Send private message
wedgey
Site Admin


Joined: 01 Mar 2006
Posts: 207
Location: three quarters of a mile from the surface of the sun

PostPosted: Fri Dec 08, 2006 10:42 am    Post subject: Reply with quote

JavaWiz wrote:
Cool eternal graciousness Wedgey. I appreciate this. And eternal graciousness foolinthehill, if you can put something together over christmas. Smile, i tried that java tutorial page you gave me, and im sorry, but i got really really lost. I think i need to approach the java programming language in an easier way. this is much MUCH MUCH harder then Pascal. I already took a few classes in Pascal, which i guess im pretty good at, but Java is really confusing me. May you put a little tutorial in a word document or something, on maybe a program, to add 2 integers? eternal graciousness. Smile


Yeah I could probably do that.

foolnthehill wrote:
Wow. That's exactly what I needed, wedgey. Thank!s Just one question: Do you know what "fudge" is for? Correct me if I'm wrong, but I'm thinking it's to prevent the yielding of inaccurate results when the distance between the center of the slime and the ball is too small.


Actually it doesn't quite make sense... that's the best idea that I can come up with too (preventing divide by 0, though I don't know why it's not just dist != 0). Maybe someone should test it out by getting the slime to land on the ball right in the middle of the slime, and see if the ball goes halfway through the slime before a collision takes place.

btw fudge = 5 in that code.
Back to top
View user's profile Send private message
JavaWiz
Inferior Human Controlled Slime


Joined: 27 Nov 2006
Posts: 8

PostPosted: Fri Dec 08, 2006 1:21 pm    Post subject: Reply with quote

Thanks Wedgey.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    oneslime.net Forum Index -> Programming All times are GMT + 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group