Be a Supporter!
Java : Applet Indepth Posted July 19th, 2007 in Programming

Java : Main

This is a tutorial.
You need to know about Applets in Java. Including how to execute and view them.
You must have intermediate Java programming skills.
Ok good.
I am assuming you know how classes work when using the Applet extension, I am going into deeper detail of the methods in the applet package.

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

Basic stuff, importing applet as well as graphic classes.

public class someClass extends Applet implements Runnable{}

You should understand the class and extends syntax. Implement Runnable basically tells Java that you will be using a run() method to execute loops, like in games and aniation done through API.

public void init(){}

This executes whatever is in the curly braces when the Applet has loaded, including pictures, objects and variables.

public void start(){
Thread someThread = new Thread();
someThread.start();
}

In the start method usually any Thread objects are initialized. Threads are lines of programming and in this case there is only one, so don't worry too much about it.

public void paint(Graphics g){
g.setColor(Color.Red); //Damn americans! everyone knows its Colour not Color...
g.fillRect(0,0,100,100);
}

The paint method uses graphics to draw whatever you have told it to draw. In this case it's a red rectangle 100 px wide and 100 px high.

public void run(){
Thread.currentThread().setPriority(Threa d.MIN_PRIORITY);
while(true){
repaint();
try{
Thread.sleep(100);
}catch(Intercept Exception ex){}
Thread.currentThread().setPriority(Threa d.MAX_PRIORITY);
}
}

Ok here is the tricky part. Java was called to run this method (run()) and it has a loop in it. The while loop is infinite since it isn't checking for anything whatsoever. repaint() calls the paint method to redraw graphics (I may cover Double Buffering in later tutorials). Thread.sleep(100) tells the current thread to stop for 100 milliseconds. It has to be in a try syntax or else Java gives you all sorts of exception errors.

Heres an example program:
import java.applet.*;
import java.awt.*;

public class someClass extends Applet implements Runnable{
int xpos = 100;
int ypos = 100;

public void init(){}

public void start(){
Thread someThread = new Thread();
someThread.start();
}

public void paint(){
g.setColor(Color.red);
g.fillOval(xpos,ypos,10,10);
}

public void run(){
Thread.currentThread().setPriority(Threa d.MIN_PRIORITY);
while(true){
repaint();
try{
someThread.sleep(100);
}catch(InterruptedException ex){}
Thread.currentThread().setPriority(Threa d.MAX_PRIORITY);
}
}

Open up JCreator (Xinox Software) or whatever you use, copy-paste, create class, create HTML Applet around 500 by 500 and voila! you will have a red circle updating itself 100 ms.

Response to: Java: Main Posted July 19th, 2007 in Programming

I'll write a tut on basic Applet usage e.g Drawing API and Images onscreen and some basic methods in the applet package

Response to: Fuck! My mouse is broken again! Posted July 19th, 2007 in General

Let go of your mouse when you're fapping

Response to: can stolen laptops be traced? Posted July 19th, 2007 in General

Unless he advertises his laptops names on a network as 'Stolen Laptop Haxxorz please dont trace'

Response to: actionscript for shooting game Posted July 19th, 2007 in Game Development

Off topic but still.... 3d in flash is possible and at times even feasible, but saying this if you do have the skills and knowledge of how to make 3d vector processing then you are a bit advanced to be using such a low level language as Actionscript... my rant sorry...

And dont used buttons for targets, theyre gay and belong on menus

Use movieclips they can behave like buttons using the on(press) or on(release) syntax

Response to: Drawing... Posted July 19th, 2007 in Game Development

Uhhh... basically you should do API hitTesting...

if(_xmouse > leftofareawhereyoucantdraw && _ymouse > topofareawhereyoucantdraw){
canDraw = false;
}else{
canDraw = true;
}

voila!

Response to: Wtf Is Wrong With Fat People? Posted July 15th, 2007 in General

I hate fat people.
They're useless.

Why would you want to be fat? it's harder to do things and therefore you are less of an asset to the human race and you should go jump in a pit of spikes like the homosexuals

there's my rants any questions and I'll answer...

Response to: Rotated Platform Collision Posted June 29th, 2007 in Game Development

Well you must realise that what you are suggesting is more complex than it seems...

I assume you are using trig. movement e.g
ball._x += Math.sin(ball._rotation*Math.PI/180) * speed
ball._y += Math.cos(ball._rotation*Math.PI/180) * speed

once thats done you need to use physics to find the theta of the balls incidence angle and the theta of the reflective angle. But I'll let you look that up for yourself :P

Response to: on press remove this MC??? Posted June 24th, 2007 in Game Development

Do you actually want to get rid of the MC or just clear it...

if you want to clear it just use clear()

Response to: hows my game look? Posted June 24th, 2007 in Game Development

Wow this is looking great! I would so pay to sponsor this! I can just think of the storyline now...

A stick is lonely so he decides to dance and the world randomly dissapears and is replaced by epileptic lines.... And he loses his neck somewhere?

[/sarcasm] btw

Response to: character movement help Posted June 23rd, 2007 in Game Development

Sigh... I hate copy and paste noobs...

Anyway if you're willing to write your own code here's a tip:
You'll need a seperate variable for your characters direction
e.g.
if(key.isDown(Key.LEFT)){
characterDirection = "left"
player._x-=10
}
if(characterDirection == "left"){
player.gotoAndStop("left")
}

Response to: Dress-Up Game. Whats in a good one? Posted June 23rd, 2007 in Game Development

Oh god... Dress up games and mouse collision games are the laziest and most pointless games
Other than the fact that dress up games can be artisitic there is no complex programming invovled...
Just like mouse avoiders, I mean come on a few hitTests here and there. And don't say 'yeah well v-cams make it look cool!' its lazy

Lines in Dynamic textboxes Posted June 23rd, 2007 in Game Development

How can you make it so your text skips lines at runtime (like return key)

Response to: Need beta testers Posted June 13th, 2007 in Game Development

ai_anarki@hotmail.com

Response to: HitTests with walls. Posted June 10th, 2007 in Game Development

// HIT RIGHT
if(wall.hitTest(player._x+player._width/2,pla yer._y,true)){
do stuff....
}
// HIT LEFT
if(wall.hitTest(player._x-player._width/2,pla yer._y,true)){
do stuff....
}
Thats a noobish version... learn to do tile engines and skip hitTest altogether

Response to: iNinja Beta Testing! Posted May 31st, 2007 in Game Development

Is this using a tiulebased engine? it is really slow you need some kind of engine to load the map... even without the blur it will lag...

Response to: My Wario Game Posted May 25th, 2007 in Game Development

You need to learn how to make tiled platformers and realistic.... everything...

Response to: Isometric Game Posted May 24th, 2007 in Game Development

I was thinking about makin a pac-man clone, but then I saw all the remakes there are on newgrounds alone...

My friend suggested paintball... What do you think?

Isometric Game Posted May 23rd, 2007 in Game Development

I'm making an engine for an Isometric game, I just need an idea for what to make it about...
Any ideas?

Response to: If you had powers... Posted May 22nd, 2007 in General

I dont know.... Its a toss up between time control and telekenisis...

But it makes me, ask in movie (e.g Xmen), why do people with telekenisis mind control weapons when you could just as easily tear all the bodily organs, blood and or bones out of someon...

just a thought

Response to: Warning To Women Posted May 12th, 2007 in General

See we wouldnt have this problem if all guys had metre long dicks.... we could just stand there and pump it out while its over the seat....

I would know >.> <.<

Response to: Bullet problem Posted May 12th, 2007 in Game Development

Uhh a few things...

Your mouselook is a little off it looks stingy, make sure everything is aligned right

And to make your bullets come out from the top of the turret, you need to fully understand sin +cos... or just steal from a tutorial like everyelse

Everything you need is here

Response to: Best three words to say after SEX! Posted May 11th, 2007 in General

did you cum?

Response to: Spore Flash Game Posted May 4th, 2007 in Game Development

Hm spore in flash?
even using AS3 this is going to be a massive challenge, I'm guessing you want to be able to compare it to the ps3 version... will it be 3d?

Response to: new pic wtf! Posted April 29th, 2007 in General

No it isnt.... Its a beaver with bannanas on its face...

Response to: Reguarding collision detection Posted April 29th, 2007 in Game Development

if(_root.whatever.hitTest(_root.player._x,_ro ot.player._y,true)){
blah blah
}

Response to: Test my game - need ideas Posted April 28th, 2007 in Game Development

Ive layed sooooo many games like this.... just like making another snake game :(

Also almost all the effects in it (e.g gravity) looks exactly like the gravity from a tutorial ive seen...

bsides that good luck!

Response to: gravity Posted April 28th, 2007 in Game Development

Rebounding of angles is much more complex... its called inverse kinematics
it is using sin. and cos. so if you're blank onyour trig. you're kinda screwed

Response to: bouncing with gravity Posted April 28th, 2007 in Game Development

Use function()s

so instead of onClipEvent(enterFrame) use onEnterFrame = function(){ blah blah}

P.S all in timeline
P.P.S vars in timeline out of enterframe func.

Response to: following enemy Posted April 28th, 2007 in Game Development

Well im bored so..... heres a really nooby one....

if(_root.enemy._x > _root.player._x){
_root.enemy._x--;
}
if(_root.enemy._x < _root.player._x){
_root.enemy._x++;
}

and repeat for _y when necessary