 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Evil_Intentions Expert Cheater
Reputation: 65
Joined: 07 Jan 2010 Posts: 214
|
Posted: Tue Aug 09, 2011 2:29 pm Post subject: slugsnack :3 |
|
|
A friend of mine wanted to make an applet version of fractalgen, so I figured it would be a good chance to break things down and make classes to handle everything. If i code up a simple test, do you mind looking over the code to see if I'm using the classes right?
It'll be in eclipse btw, working on dropping netbeans.
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Tue Aug 09, 2011 3:29 pm Post subject: |
|
|
| sure. quite busy with this week though so i can't guarantee i'll get to it immediately
|
|
| Back to top |
|
 |
Evil_Intentions Expert Cheater
Reputation: 65
Joined: 07 Jan 2010 Posts: 214
|
Posted: Tue Aug 09, 2011 3:33 pm Post subject: |
|
|
| Slugsnack wrote: | | sure. quite busy with this week though so i can't guarantee i'll get to it immediately |
That's fine, whenever you get a chance
| Code: |
package fractalgen;
import java.util.Random;
public class FractalData {
private String gs, fs, xs, ys;
public FractalData(String gs, String fs, String xs, String ys) {
this.gs = gs;
this.fs = fs;
this.xs = xs;
this.ys = ys;
}
public String getGenString() {
return this.gs;
}
public void setGenString(String gs) {
this.gs = gs;
}
public String getFString() {
return this.fs;
}
public void setFString(String fs) {
this.fs = fs;
}
public String getXString() {
return this.xs;
}
public void setXString(String xs) {
this.xs = xs;
}
public String getYString() {
return this.ys;
}
public void setYString(String ys) {
this.ys = ys;
}
public String order(int order) {
String orderStr = gs;
Random rand = new Random();
for (int i = 1; i < order; i++) {
orderStr += "*";
orderStr = orderStr.replaceAll("F", "1").replaceAll("f", "1");
orderStr = orderStr.replaceAll("X", "2").replaceAll("x", "2");
orderStr = orderStr.replaceAll("Y", "3").replaceAll("y", "3");
orderStr = orderStr.replaceAll("R", Integer.toString(rand.nextInt(4))).replaceAll("r", Integer.toString(rand.nextInt(4)));
orderStr = orderStr.replaceAll("0", gs).replaceAll("1", fs).replaceAll("2", xs).replaceAll("3", ys);
}
if (orderStr.contains(">")) {
char curChar = '0';
String saveStr = "";
String tempStr = "";
String finalStr = "";
for (int i = 0; i < orderStr.length(); i++) {
curChar = orderStr.charAt(i);
if (curChar == '>') {
for (int ii = i - 1; ii > 0; ii--) {
if (orderStr.charAt(ii) == '<') {
saveStr = new StringBuffer(tempStr).reverse().toString();
finalStr += saveStr;
finalStr = removeCharAt(finalStr, finalStr.length() - (saveStr.length() + 2));
break;
}
tempStr += orderStr.charAt(ii);
}
} else {
finalStr += curChar;
}
saveStr = "";
tempStr = "";
}
finalStr.replace('<', ' ');
return finalStr;
} else {
return orderStr;
}
}
public static String removeCharAt(String s, int pos) {
StringBuffer buf = new StringBuffer(s.length() - 1);
buf.append(s.substring(0, pos)).append(s.substring(pos + 1));
return buf.toString();
}
}
|
| Code: |
package fractalgen;
import java.awt.*;
import java.awt.geom.*;
public class TurtleGraphics {
private Graphics2D g2d;
private final double radPerDeg = Math.PI/180;
private double cd,cx,cy,nx,ny,length;
public void draw()
{
nx = cx+length*Math.cos(radPerDeg*cd);
ny = cy+length*Math.sin(radPerDeg*cd);
g2d.draw(new Line2D.Double(cx,cy,nx,ny));
cx = nx;
cy = ny;
}
public void move()
{
nx = cx+length*Math.cos(radPerDeg*cd);
ny = cy+length*Math.sin(radPerDeg*cd);
cx = nx;
cy = ny;
}
public void increment(double change)
{
this.cd+=change;
}
public TurtleGraphics(Graphics2D g2d, double cx, double cy, double cd, double length)
{
this.g2d = g2d;
this.cd = cd;
this.cx = cx;
this.cy = cy;
this.length = length;
}
public Graphics2D getGraphics() {
return g2d;
}
public void setGraphics(Graphics2D g2d) {
this.g2d = g2d;
}
public double getDirection() {
return cd;
}
public void setDirection(double cd) {
this.cd = cd;
}
public double getCurrentX() {
return cx;
}
public void setCurrentX(double cx) {
this.cx = cx;
}
public double getCurrentY() {
return cy;
}
public void setCurrentY(double cy) {
this.cy = cy;
}
public double getLength() {
return length;
}
public void setLength(double length) {
this.length = length;
}
}
|
| Code: |
package fractalgen;
import java.applet.*;
import java.awt.*;
public class FractalGenApplet extends Applet {
FractalData fd = new FractalData("F","f-Ff+F+fF-F","","");
TurtleGraphics tg;
String orderStr = fd.order(6);
char curChar;
public void paint(Graphics g)
{
tg = new TurtleGraphics((Graphics2D)g,1,getHeight()-1,0,2);
for(int i = 0; i<orderStr.length();i++)
{
curChar = orderStr.charAt(i);
if(curChar == 'F')
{
tg.draw();
}
if(curChar == 'f')
{
tg.move();
}
if(curChar == '+')
{
tg.increment(90);
}
if(curChar == '-')
{
tg.increment(-90);
}
}
}
}
|
Last edited by Evil_Intentions on Tue Aug 09, 2011 6:30 pm; edited 1 time in total |
|
| Back to top |
|
 |
Aviar³ Grandmaster Cheater
Reputation: 50
Joined: 03 Jan 2008 Posts: 655 Location: Canada
|
Posted: Tue Aug 09, 2011 4:01 pm Post subject: |
|
|
Oh pastebin and raring source folders, how I miss you so.
_________________
This is the inception of deception, checking the depth of your perception.
 |
|
| Back to top |
|
 |
Evil_Intentions Expert Cheater
Reputation: 65
Joined: 07 Jan 2010 Posts: 214
|
Posted: Tue Aug 09, 2011 4:03 pm Post subject: |
|
|
| Aviar³ wrote: | | Oh pastebin and raring source folders, how I miss you so. |
Just poastan what I had so far, will rar the source once I have the boundary detection in.
|
|
| Back to top |
|
 |
Gypsy++ Master Cheater
Reputation: -1
Joined: 25 Aug 2010 Posts: 398
|
Posted: Tue Aug 09, 2011 6:08 pm Post subject: |
|
|
| QUICK DELETE AND PM IT BEFORE THE LEECH COMES AND STEALS IT!
|
|
| Back to top |
|
 |
Evil_Intentions Expert Cheater
Reputation: 65
Joined: 07 Jan 2010 Posts: 214
|
Posted: Tue Aug 09, 2011 6:29 pm Post subject: |
|
|
| PedoGypsy wrote: | | QUICK DELETE AND PM IT BEFORE THE LEECH COMES AND STEALS IT! |
The program was always meant to be open source, both FractalGen and Muse, I was always a bit ashamed of the code and didn't release it in it's later versions. As I'm cleaning it up and getting little reviews from slug, I'll stat releasing the source to sourceforge.
People can do what they want with it :3
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Wed Aug 10, 2011 2:14 am Post subject: |
|
|
| i want you to describe to me exactly how a fractal works in terms of generations, rules, etc. this will help you think in an oop way which you are currently not doing. pretend i know nothing about fractals. how would you explain it to me and how would you explain the functional part of your program ?
|
|
| Back to top |
|
 |
Coldie ;] Guest
|
Posted: Wed Aug 10, 2011 2:51 am Post subject: |
|
|
| Slugsnack wrote: | | i want you to describe to me exactly how a fractal works in terms of generations, rules, etc. this will help you think in an oop way which you are currently not doing. pretend i know nothing about fractals. how would you explain it to me and how would you explain the functional part of your program ? |
Fractals are simple lines of code bunched together to the point where it is on continuous loop. You may use fractals to create, bond, or synchronize code to appease any one of your coding infidelities. You may constitute the many types of fractals to substitute for non-frantically fractal-genetic pieces of code.
Thus is a fractal, you use it to use it.
Hatahz gun' hate for my superior trollin'
Yep. I know my shit.
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Wed Aug 10, 2011 2:54 am Post subject: |
|
|
| Nope. If I didn't have a computer science background I wouldn't understand. You need to go programming before OOP. Also get some plastic done
|
|
| Back to top |
|
 |
Evil_Intentions Expert Cheater
Reputation: 65
Joined: 07 Jan 2010 Posts: 214
|
Posted: Wed Aug 10, 2011 3:57 am Post subject: |
|
|
Fractals are basically just self similar functions. They can be visualized through data, sound, or graphically. They are built through repetition with a seed, or starting point. Some undergo an equation after which the answer becomes the new variable, and so on. Mine work slightly differently, relying on a string replacement system.
In a string replacement system, an alphabet of tokens is defined, my program uses many, but for this I will only use "A" and "B." After the tokens are defined, rules are defined. These rules tell us what replaces each token. Say our rules are:
A -> AB
B -> A
We then construct our starting string, our axiom, our atom, our seed. For simplicity, it will be "AB." Our first order will always be our atom. Order is how many times you've completed the string replacement. If our first order is "AB," after applying our rules, our second order is "ABA" which can be split up like so to clarify"(AB)(A)" This 2nd order then becomes our new atom to build our 3rd order. This is exactly like an equation method, but is simpler to grasp and more user friendly. With a new atom of "ABA" our next, or third, order is ABAAB or (AB)(A)(AB).
My fractalData class handles this entire portion of the programming. It provides a constructor for setting up the atom and replacement rules for a set of FractalData. It also provides a function, "order", to create the specified order of the fractal, returning it as a string. After we have this, we choose to represent it graphically using what is known as "Turtle Graphics." This is the Idea of having an imaginary "turtle" with a current position and a direction. The "turtle" moves to a new direction based on a set length and it's direction, arriving at a new point on the drawing grid.
All of the drawing is handled in my class TurtleGraphics. It provides everything needed to work with my program and my FractalData class.
Also @Coldie, shut the hell up and read a book for once. A factal is not a piece of code, but can be represented in code. It is not a continuous loop, it operates on iterations. Fractals are not used to augment coding or programming. But I'm sure you're just "trolling." Or as we like to call it, making yourself look like a total fucktard.
Back @slug. I think I've split it up and don't see myself needing any other classes. I have one that contains the main code for the applet, one for handling all data fractal related, and another for the actual drawing.
|
|
| Back to top |
|
 |
Coldie ;] Guest
|
Posted: Wed Aug 10, 2011 1:34 pm Post subject: |
|
|
| Coldie ;] wrote: | | Slugsnack wrote: | | i want you to describe to me exactly how a fractal works in terms of generations, rules, etc. this will help you think in an oop way which you are currently not doing. pretend i know nothing about fractals. how would you explain it to me and how would you explain the functional part of your program ? |
Fractals are simple lines of code bunched together to the point where it is on continuous loop. You may use fractals to create, bond, or synchronize code to appease any one of your coding infidelities. You may constitute the many types of fractals to substitute for non-frantically fractal-genetic pieces of code.
Thus is a fractal, you use it to use it.
Hatahz gun' hate for my superior trollin'
Yep. I know my shit. |
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Wed Aug 10, 2011 3:56 pm Post subject: |
|
|
| now i think about it i suppose fractals are not the best example of making something fit the oop paradigm. mvc is definitely the way to go but it sounds like you're doing that already. show me the project when it's done anyway. consider asking on stackoverflow. people there seem to have a lot of time to put thought into and answer these sorts of questions
|
|
| Back to top |
|
 |
Evil_Intentions Expert Cheater
Reputation: 65
Joined: 07 Jan 2010 Posts: 214
|
Posted: Wed Aug 10, 2011 4:09 pm Post subject: |
|
|
| Slugsnack wrote: | | now i think about it i suppose fractals are not the best example of making something fit the oop paradigm. mvc is definitely the way to go but it sounds like you're doing that already. show me the project when it's done anyway. consider asking on stackoverflow. people there seem to have a lot of time to put thought into and answer these sorts of questions |
Wasn't so much of a question as a quick review. I just wanted to make sure I have the right idea about classes and using them, and that I'm breaking my program down properly. I think I've accomplished that, I just wanted your opinion on it as well.
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Wed Aug 10, 2011 4:21 pm Post subject: |
|
|
| nah really. there are a lot of very good programmers on SO. give it a go and you'll get good feedback and learn a lot
|
|
| Back to top |
|
 |
|
|
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 You cannot attach files in this forum You can download files in this forum
|
|