This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-07-31 17:11:36

Proanimation
Scratcher
Registered: 2011-08-09
Posts: 47

Scratch to java project

Hey the project is coming back!

I am working on a project that you type in scratch code and the project will then process and give you a string of code to type into a note document to be compiled into a .class file. So I am looking for someone who knows Java (NOT JavaScript), java swing, awt, ect. So if you do know that stuff just post a reply and I'll show you what I was working on and what I need help with. Note: I will not be a snob and say I created it all by myself  50 50 credit will be given. Also the project will have to be updated with each Java update.

Here is the block codes(scratch code):
when gf clicked   is the code for:

 when gf clicked 
forever   code inside the block end is the code for:
forever 
Put something in here.
end 
If you haven't noticed we are using the block codes for the forms that have the scratch blocks tag.
You can find all the codes here.

To become part of the team please state what you know about Java and some Java code. Also state the part of the project you want to work on.

Think this should be in the Advanced topics? Just leave a post saying advanced topics or collaboration.

You can find the incompleate non-working version here.

members
>Proanimation (me) - creating project
>YMIBANWAH - helped with some Java code
> slayerrobe7 - helping with Java code

need to be done
> create an ad project
> create a block code giving project (see me for further explaination)
> Java code for separate blocks (see me for further explaination)
These are the parts of the project that have to be done

---------------------------------------------------------------------------------------------------
http://i46.tinypic.com/2873f55.png

Last edited by Proanimation (2012-11-05 18:23:49)

Offline

 

#2 2012-08-02 09:58:23

fille1237
Scratcher
Registered: 2010-04-29
Posts: 4

Re: Scratch to java project

I don't know java but i still want to support your awesome project by bumping this thread

Offline

 

#3 2012-08-02 14:07:28

YMIBANWAH
Scratcher
Registered: 2012-06-26
Posts: 100+

Re: Scratch to java project

I am learning java i could help with some things possibly. I could do if loops and things. Plus variables and some operators. It will require a lot of scripts because java is object oriented but i can still help. You will still want another java guy.


Ingarts read it today!

Offline

 

#4 2012-08-12 14:47:00

Proanimation
Scratcher
Registered: 2011-08-09
Posts: 47

Re: Scratch to java project

Yeah I'll definitely need another person that knows Java. I will need your help with the loops. I know how to make a GUI in Java but, I don't know about loops, the if operation (see I don't even know how to type it) and such. Reply back to me on how to use different loops and such.I have already got started with the project I will release the current version tomorrow.

Offline

 

#5 2012-08-14 11:13:41

YMIBANWAH
Scratcher
Registered: 2012-06-26
Posts: 100+

Re: Scratch to java project

This is the infinite loop which could be used for forever

// infinite loop
for (; ;) {
    // your code goes here

This is the if-then which could be used for if

if (your condition goes here) {
  // your code goes here

This is the if-then-else

if  (your condition goes here) {
   // the first method goes here
} else {
    // the second method goes here
}

Last edited by YMIBANWAH (2012-08-14 11:15:52)


Ingarts read it today!

Offline

 

#6 2012-08-14 13:07:23

Proanimation
Scratcher
Registered: 2011-08-09
Posts: 47

Re: Scratch to java project

Thanks! I will definitely be using them. Can you try to make a program in scratch that singles out words (see first post for example) so we can finally make some headway with the converter.

Offline

 

#7 2012-08-15 21:32:47

dvd4
Scratcher
Registered: 2010-06-30
Posts: 1000+

Re: Scratch to java project

YMIBANWAH wrote:

This is the infinite loop which could be used for forever

// infinite loop
for (;  wink  {
    // your code goes here

This is the if-then which could be used for if

if (your condition goes here) {
  // your code goes here

This is the if-then-else

if  (your condition goes here) {
   // the first method goes here
} else {
    // the second method goes here
}

the thing with infinite loops is that there is no execution pause time


I made a mod  big_smile  It's called blook!
http://i49.tinypic.com/16ia63p.png

Offline

 

#8 2012-08-16 00:28:37

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: Scratch to java project

Is java really the best language to do this in? There are simpler ones with equal abilities, python for example, requires little syntax, and loops are easier (while 1: for a forever, break to end the loop)


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#9 2012-08-16 19:03:47

Proanimation
Scratcher
Registered: 2011-08-09
Posts: 47

Re: Scratch to java project

zammer990 wrote:

Is java really the best language to do this in? There are simpler ones with equal abilities, python for example, requires little syntax, and loops are easier (while 1: for a forever, break to end the loop)

First of all if I were to finally make this work or complete it you could easily change it to a Scratch to Python converter easily. Also I really don't think it matters because all of the programming languages all have one thing in common. To be used or in other words they all can be turned into a .exe file.

Offline

 

#10 2012-08-16 20:51:59

Thrystor
Scratcher
Registered: 2011-04-10
Posts: 100+

Re: Scratch to java project

I know Java and all that, but there's already a tool for this. It works better too. You don't do any typing, you just give it a Scratch project (.sb) and convert it straight into a Java archive (.jar). No typing in long lines of code and no manually compiling it.


http://codersshed.webuda.com/favicon.ico Cool stuff awaits the technically literate...

Offline

 

#11 2012-08-16 21:27:43

Proanimation
Scratcher
Registered: 2011-08-09
Posts: 47

Re: Scratch to java project

Thrystor wrote:

I know Java and all that, but there's already a tool for this. It works better too. You don't do any typing, you just give it a Scratch project (.sb) and convert it straight into a Java archive (.jar). No typing in long lines of code and no manually compiling it.

Yes I have seen that but with a scratch project as the converter it will work for all versions of scratch. So when scratch 2.0 comes out the .jar file won't work because scratch 2.0 is rewritten in flash but with this all you have to do is type in the block codes and it will give you a string of Java code to compile into a .class file. Also someone could easy remix the converter so that it converts it into a different programming language such as C++,Python,JavaScript,ect.

Offline

 

#12 2012-08-16 22:48:47

slayerrobe7
Scratcher
Registered: 2011-06-24
Posts: 500+

Re: Scratch to java project

i ave read several books on Java and have a good grasp on the language...(I will probably be more help after my next investment) however i could be lots of help now

here is a project i made in one of my tutorial books. (i just don't want to type stuff out right not so im copy pasting)

Code:

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

class PrimeFinder extends JFrame implements Runnable, ActionListener {
    Thread go;
    JLabel howManyLabel = new JLabel("Quantity: ");
    JTextField howMany = new JTextField("400", 10);
    JButton display = new JButton("Display primes");
    JTextArea primes = new JTextArea(8, 40);

    PrimeFinder() {
        super("Find Prime Numbers");
        setSize(400, 300);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        BorderLayout bord = new BorderLayout();
        setLayout(bord);
        display.addActionListener(this);

        JPanel topPanel = new JPanel();
        topPanel.add(howManyLabel);
        topPanel.add(howMany);
        topPanel.add(display);
        add(topPanel, BorderLayout.NORTH);

        primes.setLineWrap(true);
        JScrollPane textPane = new JScrollPane(primes);
        add(textPane, BorderLayout.CENTER);

        setVisible(true);
    }

    public void actionPerformed(ActionEvent event) {
        display.setEnabled(false);
        if (go == null) {
            go = new Thread(this);
            go.start();
        }
    }

    public void run() {
        int quantity = Integer.parseInt(howMany.getText());
        int numPrimes = 0;
        // candidate: the number that might be prime
        int candidate = 2;
        primes.append("First " + quantity + " primes:");
        while (numPrimes < quantity) {
            if (isPrime(candidate)) {
                primes.append(candidate + " ");
                numPrimes++;
            }
            candidate++;
        }
    }

    public static boolean isPrime(int checkNumber) {
        double root = Math.sqrt(checkNumber);
        for (int i = 2; i <= root; i++) {
            if (checkNumber % i == 0) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] arguments) {
        PrimeFinder fp = new PrimeFinder();
    }
}

when this is run it finds all prime numbers between 1 and a specified number

Last edited by slayerrobe7 (2012-08-16 22:55:56)


!!!When it comes to Scratch2.0 I am totally like freaking out!!!

Offline

 

#13 2012-08-17 10:31:54

Proanimation
Scratcher
Registered: 2011-08-09
Posts: 47

Re: Scratch to java project

slayerrobe7 wrote:

i ave read several books on Java and have a good grasp on the language...(I will probably be more help after my next investment) however i could be lots of help now

I will add you to the list of members.  smile

Offline

 

#14 2012-08-17 19:45:34

slayerrobe7
Scratcher
Registered: 2011-06-24
Posts: 500+

Re: Scratch to java project

Proanimation wrote:

slayerrobe7 wrote:

i ave read several books on Java and have a good grasp on the language...(I will probably be more help after my next investment) however i could be lots of help now

I will add you to the list of members.  smile

thank you


!!!When it comes to Scratch2.0 I am totally like freaking out!!!

Offline

 

#15 2012-08-18 08:33:52

Proanimation
Scratcher
Registered: 2011-08-09
Posts: 47

Re: Scratch to java project

slayerrobe7 wrote:

Proanimation wrote:

slayerrobe7 wrote:

i ave read several books on Java and have a good grasp on the language...(I will probably be more help after my next investment) however i could be lots of help now

I will add you to the list of members.  smile

thank you

Can you tell me which part of the project you want to work on?

Offline

 

#16 2012-08-18 14:34:12

slayerrobe7
Scratcher
Registered: 2011-06-24
Posts: 500+

Re: Scratch to java project

Proanimation wrote:

slayerrobe7 wrote:

Proanimation wrote:


I will add you to the list of members.  smile

thank you

Can you tell me which part of the project you want to work on?

coding in scratch and java


!!!When it comes to Scratch2.0 I am totally like freaking out!!!

Offline

 

#17 2012-08-18 21:14:46

Proanimation
Scratcher
Registered: 2011-08-09
Posts: 47

Re: Scratch to java project

slayerrobe7 wrote:

Proanimation wrote:

slayerrobe7 wrote:


thank you

Can you tell me which part of the project you want to work on?

coding in scratch and java

What I mean by picking a part is to pick from the parts on the first post. (look at the fist post I updated it)

Offline

 

#18 2012-08-19 10:49:54

YMIBANWAH
Scratcher
Registered: 2012-06-26
Posts: 100+

Re: Scratch to java project

What is java code for separate blocks. I might be able to do that. If you want code for different blocks then I can do that. It might be a little over a week before I can start though.


Ingarts read it today!

Offline

 

#19 2012-08-20 00:33:40

slayerrobe7
Scratcher
Registered: 2011-06-24
Posts: 500+

Re: Scratch to java project

Proanimation wrote:

slayerrobe7 wrote:

Proanimation wrote:


Can you tell me which part of the project you want to work on?

coding in scratch and java

What I mean by picking a part is to pick from the parts on the first post. (look at the fist post I updated it)

the java code for separate blocks.


!!!When it comes to Scratch2.0 I am totally like freaking out!!!

Offline

 

#20 2012-08-20 09:12:22

Proanimation
Scratcher
Registered: 2011-08-09
Posts: 47

Re: Scratch to java project

YMIBANWAH wrote:

What is java code for separate blocks. I might be able to do that. If you want code for different blocks then I can do that. It might be a little over a week before I can start though.

The Java code for different blocks means that you pick one block at a time and create some code in Java that would do the same thing as the block.
Example: I picked the forever block so I would use:

Code:

for (; ;) 
{
//other code goes in here
}

Offline

 

#21 2012-08-21 11:15:14

slayerrobe7
Scratcher
Registered: 2011-06-24
Posts: 500+

Re: Scratch to java project

bump


!!!When it comes to Scratch2.0 I am totally like freaking out!!!

Offline

 

#22 2012-08-22 00:03:59

slayerrobe7
Scratcher
Registered: 2011-06-24
Posts: 500+

Re: Scratch to java project

now what do i do


!!!When it comes to Scratch2.0 I am totally like freaking out!!!

Offline

 

#23 2012-08-22 08:44:17

Proanimation
Scratcher
Registered: 2011-08-09
Posts: 47

Re: Scratch to java project

slayerrobe7 wrote:

now what do i do

Go and start on making Java code for a block(s).
If you don't know what I mean look at the post that is three posts away from this post.

Offline

 

#24 2012-08-22 11:53:50

slayerrobe7
Scratcher
Registered: 2011-06-24
Posts: 500+

Re: Scratch to java project

alright here is a code that all games will need to run inside for it opens the window..
note: the symbol <> in this means that these areas will be different for every project

Code:

//First it would be best to have the necessary imports defined..
import javax.swing.*;
import java.awt.event*;
import java.awt.*;

//this code may get confusing 

public class <projectNAME> extends JFrame implements KeyListener, ActionListener {
//code will go here

    <name here>d() {
        super("<nameHere>");
        setSize(SIZE HERE);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //code will go here
        setVisible(true);
    }
    
    Public static void main(String[] args) {
         <name of project here> pr = new <name of project here>
}

!!!When it comes to Scratch2.0 I am totally like freaking out!!!

Offline

 

#25 2012-08-22 12:39:20

Proanimation
Scratcher
Registered: 2011-08-09
Posts: 47

Re: Scratch to java project

Thanks I will add it to the converter.
Though I had the converter add the imports only when they were necessary

Last edited by Proanimation (2012-08-22 12:41:21)

Offline

 

Board footer