Welcome to our forums...

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Forum Statistics

  • Forum Members:
  • Total Threads:
  • Total Posts: 1
There are 1 users currently browsing forums.
Java Programming Created by Sun Microsystems, Java remains to be one of the most powerful, cross-platform languages of choice by professionals everywhere. Capable of creating advanced desktop applications and web services, Java is tough to master, so ask your questions here.

Reply
  #1  
Old 06-07-2008
Graduate Student
 
Join Date: Dec 2007
Location: The Draco Supercluster
Age: 16
Posts: 410
Rep Power: 0
Aepos is on a distinguished road
CollisionScript.java -- Nears Incompletion

Hey, you guys. [sarcasm]Well, I just have to say, "What a great idea to stick 'Java Programming' in such an easy-to-find, manageable location!"[/sarcasm]

Enough said. I'm currently working on an applet source for my newest series of noob-friendly tutorials. Too early in the morning--too tired.

Here's the **** I jotted down in a minute or two. See if you guys can improve the semantics or pragmatics (however, I seem to have my prag's down-pat). It's supposed to be like one of those boring bouncing "RCA" logos bouncing from wall to wall on your television screen when you've been sitting idle too long without a good DVD. It needs to go slower and implement the directional enumerators to dictate which direction the sprite should move in terms of diagonal directions. There still needs to be wall collision detector and change the enumerator value accordingly.

Code:
/* Author:  Brandon Zimmerman
 * E-mail:  b-zimmerman@live.com
 * Created: 06/07/08; 2:47 AM
 * 
 * (c) 2008 Circa Software Studios
 */

import java.awt.*;
import java.applet.*;

public class BounceEffect extends Applet {    
    enum Direction {
        NW,SW,NE,SE
    }
    public void paint(Graphics g) {
        Direction directionOfSprite = Direction.SE;
        byte xPos = 5;
        byte yPos = 5;
        g.setColor(Color.BLACK);
        g.fillRect(0,0,300,250);
        for (;;) {
            g.setColor(Color.BLACK);
            g.drawRect(xPos,yPos,2,2);
            g.setColor(Color.GREEN);
            if (directionOfSprite == Direction.SE)
                g.drawRect(++xPos,++yPos,2,2);
            else if (directionOfSprite == Direction.NE)
                g.drawRect(++xPos,--yPos,2,2);
            else if (directionOfSprite == Direction.SW)
                g.drawRect(--xPos,++yPos,2,2);
            else
                g.drawRect(--xPos,--yPos,2,2);
        }
    }    
}
Thanks for your help you guys. If you want to simply post the source, that would do just nicely.

- Brandon
__________________
· · ÷¦÷ · · · ÷¦÷ · · · ÷¦÷ · · · ÷¦÷ · · · ÷¦÷ · · · ÷¦÷ · ·
A · S · C · I · I · · A · D · D · I · C · T · I · O · N
· · ÷¦÷ · · · ÷¦÷ · · · ÷¦÷ · · · ÷¦÷ · · · ÷¦÷ · · · ÷¦÷ · ·
Reply With Quote


Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On