Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added CurrentExe/application.windows32.zip
Binary file not shown.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# RoboSim
Starting a project for simulating various kind of robots.
Build on Processing IDE. Buttons.txt is a data file for the names, locations and sizes of the buttons and it is necessary for app to work.
V1.0 2016-11-01
1 change: 1 addition & 0 deletions V1.0/Exe/application.windows32/Buttons.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4 Up 200 200 20 Down 200 600 20 Left 100 400 20 Right 300 400 20
Binary file added V1.0/Exe/application.windows32/RoboSim.exe
Binary file not shown.
Binary file added V1.0/Exe/application.windows32/lib/RoboSim.jar
Binary file not shown.
Binary file added V1.0/Exe/application.windows32/lib/core.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added V1.0/Exe/application.windows32/lib/jogl-all.jar
Binary file not shown.
22 changes: 22 additions & 0 deletions V1.0/Exe/application.windows32/source/Car.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class car {
private PVector loc=new PVector(150, 200);
float dimx=40,dimy=40;
private void UpdateLocation()
{////////
if (debug)
println(I.rMloc('x'));
////////


loc.set(I.rMloc('x'), I.rMloc('y'));
}

private void display()
{
fill(200);
pushMatrix();
translate(loc.x+dimx/4, loc.y+dimy/4);
rect(-dimx/2, -dimy/2, dimx/2, dimy/2);
popMatrix();
}
}
Empty file.
227 changes: 227 additions & 0 deletions V1.0/Exe/application.windows32/source/RoboSim.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
import processing.core.*;
import processing.data.*;
import processing.event.*;
import processing.opengl.*;

import java.util.HashMap;
import java.util.ArrayList;
import java.io.File;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;

public class RoboSim extends PApplet {

boolean debug=false;
In I=new In();
car Car=new car();
public void setup()
{
background(0);
I.createButtons();
frameRate(30);
}
public void draw()
{ background(0);
I.getinput();
I.display();

Car.UpdateLocation();
Car.display();
I.reset();
}
class car {
private PVector loc=new PVector(150, 200);
float dimx=40,dimy=40;
private void UpdateLocation()
{////////
if (debug)
println(I.rMloc('x'));
////////


loc.set(I.rMloc('x'), I.rMloc('y'));
}

private void display()
{
fill(200);
pushMatrix();
translate(loc.x+dimx/4, loc.y+dimy/4);
rect(-dimx/2, -dimy/2, dimx/2, dimy/2);
popMatrix();
}
}


public class In { //<>// //<>// //<>// //<>// //<>// //<>//
/////Button class/////
class button
{
private float x, y, s;
private String name;
public void setInfo(String aname, float ax, float ay, float as)
{
x=ax;
y=ay;
s=as;
name=aname;
}
public void dispButton()
{
textSize(15);
if (pressed())
fill(255, 255, 0, 255);
else
fill(255, 255);
ellipse(x, y, s, s);
fill(255,0,0);
text(name, x-s, y+s*1.5f);
}
public void dispNameWithState(float ax,float ay)
{textSize(10);
fill(255);
text(name,ax,ay);
if(pressed())
text("true",ax+40,ay);
else
text("false",ax+40,ay);
}
public String returnName()
{
return(name);
}
public boolean pressed()
{
boolean c=false;
if (mousePressed)
if ((abs(x-mouseX)<s)&&(abs(x-mouseX)>0)&&(abs(y-mouseY)<s)&&(abs(y-mouseY)>0))
{ ////////
if (debug)
println("pressed");
////////
c= true;
} else
c= false;

return c;
}
}
/////End/////

private float mx, my, ik, mb;
private int nButtons;
public button[] Buttons=new button[20];


private void getinput() {
mx=mouseX;
my=mouseY;
ik=key;
mb=mouseButton;
}

private void reset()
{ mb=0;
mx=0;
my=0;
ik=0;
}

public float rMloc(char w)
{float val=-1;
if(w=='x')
val=(mx);
if(w=='y')
val=(my);
return(val);
}
private void createButtons()
{
/////Load File/////
String[] lines;
int index = 1;
lines = loadStrings("Buttons.txt");

/////End/////
/////Find number of buttons/////
String[] piece=split(lines[0], ' ');
nButtons=Integer.parseInt(piece[0]);
/////End/////

////////
if (debug)
{print("Number of buttons");
println(nButtons);}
///////


/////Init Buttons/////
//

for (int i=0; i<nButtons; i++)
Buttons[i]=new button();
/////End/////
/////Set Button information/////
for (int n=0; index < nButtons*4-1; index+=4, n++) {

////////
if (debug)
{ print("Index ");
println(index);
print("N ");
println(n);}
////////

String[] pieces = split(lines[0], ' ');

////////
if (debug)
{
print("Button name ");
println(pieces[index]);
print("Button X ");
println(Float.parseFloat(pieces[index+1]));
print("Button Y ") ;
println(pieces[index+2]);
print("Button size ");
println(pieces[index+3]);
}
///////
Buttons[n].setInfo(pieces[index], Float.parseFloat(pieces[index+1]), Float.parseFloat(pieces[index+2]), Float.parseFloat(pieces[index+3]));
}
/////End/////
}

public void display()
{
for (int i=0; i<nButtons; i++)
{ Buttons[i].dispButton();
Buttons[i].dispNameWithState(20,100+i*20);
}
textSize(10);
fill(255);
text("Mouse - ",20,20);
text((int)mb,60,20);
text("MouseX - ",20,40);
text(mx,60,40);
text("MouseY - ",20,60);
text(my,60,60);
text("Key int,char- ",20,80);
text((int)ik,90,80);
text((char)ik,120,80);

}
}
public void settings() { size(400,800); }
static public void main(String[] passedArgs) {
String[] appletArgs = new String[] { "RoboSim" };
if (passedArgs != null) {
PApplet.main(concat(appletArgs, passedArgs));
} else {
PApplet.main(appletArgs);
}
}
}
34 changes: 17 additions & 17 deletions RoboSim.pde → .../application.windows32/source/RoboSim.pde
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
boolean debug=false;
In I=new In();
car Car=new car();
void setup()
{size(400,800);
background(0);
I.createButtons();
frameRate(30);
}
void draw()
{ background(0);
I.getinput();
I.display();
Car.UpdateLocation();
Car.display();
I.reset();
boolean debug=false;
In I=new In();
car Car=new car();
void setup()
{size(400,800);
background(0);
I.createButtons();
frameRate(30);
}
void draw()
{ background(0);
I.getinput();
I.display();

Car.UpdateLocation();
Car.display();
I.reset();
}
Loading