1
Advertise Your Board / Rpg Makers
« on: February 13, 2008, 06:45:55 pm »
Hey guys and gals go to www.rpgmakers.tk to learn how to make a rpg based game!
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
import java.applet.*;
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Robot;
import java.util.Random;
public class Main extends Applet implements Runnable {
public void wait(int time){
try {
Thread.sleep(time);
} catch (InterruptedException e) {
}
}
public void moveMouse(int x,int y) {
Robot rob=null;
try {
rob = new Robot();
} catch (AWTException e) {
}
rob.mouseMove(x,y);
}
public int random(int ran) {
Random Ran = new Random();
return 0+Ran.nextInt(ran);
}
public boolean more(int a, int b ) {
boolean ret = false;
if (a > b) {
ret = false;
}else {
ret = true;
}
return ret;
}
public void move(int x){
int yspeed=0,ypos=50;
int a=10,b=x;
moveMouse(10,50);
wait(100);
for (int i = 10; i < b- 4; i++){
for (int c = -1; c < random(3); c++){
yspeed = c;
} if (i < b / a * 9) {
switch (yspeed) {
case -1 : yspeed= +1;break;
case +1 : yspeed= -1;break;
default : yspeed= 0; break;
}
if (more ( ypos, i)==true) {
for (int w = 2; w < 2; w--){
yspeed = w;
} if ( ypos > i) {
yspeed = +1;
}
}
}
ypos += yspeed;
moveMouse(i,ypos);
wait(random(20));
}
moveMouse(x,50);
}
public void init() {
move(200);
}
public void run(){
}
public void start(){
Thread th = new Thread (this);
th.start();
}
}
javac -cp . *.java
public class HelloJava
{
public static void main(String[] args)
{
JFrame frame = new JFrame("Hello, Java!");
JLabel label = new JLabel("Hello, Java!");
frame.add(label);
frame.setSize(300, 300);
frame.setVisible(true);
}
}
javac -cp . HelloJava.java
java -cp . HelloJava
public class HelloJava
public static void main(String[] args)
JFrame frame = new JFrame("Hello, Java!");
JLabel label = new JLabel("Hello, Java!");
frame.add(label);
frame.setSize(300, 300);
frame.setVisible(true);
/*Script in C++. Rock paper sicrrors!. Enjoy.*/
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
srand((unsigned)time(0));
int choice;
int againchoice;
int computerchoice = (rand()%2)+1;
cout <<"Type 0 for Rock, 1 for Paper and 2 for Scissors.\n";
cin >> choice;
if (choice == 0)
{
if (computerchoice == 0)
cout << "It has resulted in a Tie!\n\n";
else if (computerchoice == 1)
cout << "Paper has beaten Rock. You have lost!\n\n";
else if (computerchoice == 2)
cout << "Rock has beaten Scissors. You have won!\n\n";
}
if (choice == 1)
{
if (computerchoice == 0)
cout << "It has resulted in a Tie!\n\n";
else if (computerchoice == 1)
cout << "Paper has beaten Rock. You have won!\n\n";
else if (computerchoice == 2)
cout << "Scissors has beaten Paper. You have lost!\n\n";
}
if (choice == 2)
{
if (computerchoice == 0)
cout << "It has resulted in a Tie!\n\n";
else if (computerchoice == 1)
cout << "Scissors has beaten Paper. You have won\n\n";
else if (computerchoice == 2)
cout << "Rock has beaten Scissors. You have lost!\n\n";
}
cout << "Would you like to play again? 1 for Yes and 2 for No.\n";
cin >> againchoice;
if (againchoice == 1)
{
system("cls");
return main();
}
else if (againchoice == 2)
{
system("EXIT");
}
}
Can't compile? I'll upload the .exe. (C++ compiles to .exe)Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Function FindColor(Color As Long, X1 As Long, Y1 As Long, X2 As Long, Y2 As Long, _
Window As Long) As POINTAPI
Dim xx As Long, yy As Long, TestDC As Long, WndRECT As RECT, temp As POINTAPI
TestDC = GetDC(Window)
For yy = Y1 To Y2
For xx = X1 To X2
If GetPixel(TestDC, xx, yy) = Color Then
temp.X = xx
temp.Y = yy
FindColor = temp
Exit Function
End If
DoEvents
Next xx
Next yy
FindColor.X = -1
FindColor.Y = -1
End Function