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

#126 2012-02-27 17:12:10

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Java Official Topic

ProgrammingFreak wrote:

wmays wrote:

Just wondering, but is it possible to define methods like for? Sort of like this...

Code:

repeat(10) {
//code to be executed
}

Is there a way to define the repeat(){} method? I'm making a library for scratch users who want to learn java... it will be like Scratch (sorta).

I'm thinking this kind of code? (I'm still learning  tongue  )

Code:

static void repeat(int num) {
     for (int i = 0; i < num; i++) {
     }  
}

Um... that wouldn't actually do anything, other than go through a loop that does nothing num times.  tongue

ProgrammingFreak wrote:

Harakou wrote:

@ProgrammingFreak: What's Snap? I can't say I've heard of it.  hmm

Really? I think you would enjoy it.  smile
It's an online version of Scratch that Jens and bharvey are developing.  big_smile
Check it out here. Hope you enjoy. I've only played with it a little.  wink

Oh, interesting! From what I see... it's basically online BYOB?


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#127 2012-02-27 17:20:50

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Java Official Topic

Harakou wrote:

ProgrammingFreak wrote:

wmays wrote:

Just wondering, but is it possible to define methods like for? Sort of like this...

Code:

repeat(10) {
//code to be executed
}

Is there a way to define the repeat(){} method? I'm making a library for scratch users who want to learn java... it will be like Scratch (sorta).

I'm thinking this kind of code? (I'm still learning  tongue  )

Code:

static void repeat(int num) {
     for (int i = 0; i < num; i++) {
     }  
}

Um... that wouldn't actually do anything, other than go through a loop that does nothing num times.  tongue

Well, I know that.  tongue
I was just making that the example. I was wondering how you could have the code to repeat. Oh wait a minute.
Can you have a statement block as an argument like in Javascript?
Then you could do something like:

Code:

static void repeat(int num, /* place for block code argument */) {
     for (int i = 0; i < num; i++) {
          /* run block code /*
     }  
}

Harakou wrote:

ProgrammingFreak wrote:

Harakou wrote:

@ProgrammingFreak: What's Snap? I can't say I've heard of it.  hmm

Really? I think you would enjoy it.  smile
It's an online version of Scratch that Jens and bharvey are developing.  big_smile
Check it out here. Hope you enjoy. I've only played with it a little.  wink

Oh, interesting! From what I see... it's basically online BYOB?

Yes, that's what it is.  smile

Offline

 

#128 2012-02-27 18:01:03

Mokat
Scratcher
Registered: 2011-12-08
Posts: 1000+

Re: Java Official Topic

16Skittles wrote:

*RAGE AT HOW SCHOOL BLOCKS THE DOWNLOAD OF SLICK-UTIL!!!*
(It's a library to make it easier to load graphics and stuff for use with openGL)

I know how you feel, man.


http://www.eggcave.com/egg/977371.pnghttp://www.eggcave.com/egg/977376.pnghttp://www.eggcave.com/egg/1005291.pnghttp://www.eggcave.com/egg/996745.png

Offline

 

#129 2012-02-27 20:26:11

16Skittles
Scratcher
Registered: 2009-08-26
Posts: 1000+

Re: Java Official Topic

Working on making Pong  big_smile  I have movement down, I just need scorekeeping, ball mechanics, and a bit more left.


http://16skittles.tk/sig.png
Are you a student? Check out OnSchedule!

Offline

 

#130 2012-02-28 01:37:22

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Java Official Topic

Sweet, i'd like to try it :3


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#131 2012-02-28 07:21:24

Nexstudent
Scratcher
Registered: 2010-02-07
Posts: 1000+

Re: Java Official Topic

I might try learning this, cus I want to mod minecraft soooo bad  big_smile


http://img696.imageshack.us/img696/9325/vedder.jpg

Offline

 

#132 2012-02-28 10:00:37

16Skittles
Scratcher
Registered: 2009-08-26
Posts: 1000+

Re: Java Official Topic

Everyone interested stay tuned for the first Undercover Study Hall Release of ALLCAPSRAGE studios! it will be available as a .zip file with all necessary libraries, images, class files and .java source files.


http://16skittles.tk/sig.png
Are you a student? Check out OnSchedule!

Offline

 

#133 2012-02-28 10:01:52

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Java Official Topic

Sweet, ALLCAPSRAGESTUDIO is your company thing then? And yes, i'm interested.


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#134 2012-02-28 10:12:13

16Skittles
Scratcher
Registered: 2009-08-26
Posts: 1000+

Re: Java Official Topic

ugh. Exporting this seems like a pan, maybe it will be tomorrow XD I hae about 10 more minutes to find a solution. PROTIP: Only announce something if you're sure it's gonna work.  wink


http://16skittles.tk/sig.png
Are you a student? Check out OnSchedule!

Offline

 

#135 2012-02-28 10:20:01

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Java Official Topic

Lol, good luck :3


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#136 2012-02-28 10:25:47

16Skittles
Scratcher
Registered: 2009-08-26
Posts: 1000+

Re: Java Official Topic

yep, it will probably be tomorrow first period. (any time between 8:00 CST and 9:25 CST) I COMPLETELY FORGOT about LWJGL's natives! Eclipse completely left them out!


http://16skittles.tk/sig.png
Are you a student? Check out OnSchedule!

Offline

 

#137 2012-02-28 10:35:35

GameHutSoftware
Scratcher
Registered: 2010-04-24
Posts: 1000+

Re: Java Official Topic

does anyone know how to make something wait until a button is pressed?
ive tried making a loop raise a bogus variable (1) until a different variable (2) is a certain number

the button changes the other variable (2) by one but only if the variable (2) is 0

but it just gets unhappy and freezes and turns black

Last edited by GameHutSoftware (2012-02-28 10:38:48)


Lurking more than posting, but still here.

Offline

 

#138 2012-02-28 12:42:55

poopo
Scratcher
Registered: 2009-09-20
Posts: 1000+

Re: Java Official Topic

GameHutSoftware wrote:

does anyone know how to make something wait until a button is pressed?
ive tried making a loop raise a bogus variable (1) until a different variable (2) is a certain number

the button changes the other variable (2) by one but only if the variable (2) is 0

but it just gets unhappy and freezes and turns black

boolean mybuttonpressed = false
While(!mybuttonpressed){
}
public void keyPressed(KeyEvent ke)
{
    if(ke.keyText(ke.keyCode) == "space")
        mybuttonpressed = true;
}
sloppy and unterminatable but it works.


http://i45.tinypic.com/28rnqki.jpg

Offline

 

#139 2012-02-28 13:02:45

muppetds
Scratcher
Registered: 2011-02-11
Posts: 1000+

Re: Java Official Topic

I'm learning it as well


SCRATCH'S PARTLY INSANE RESIDENT 
http://internetometer.com/imagesmall/31691.pnghttp://bluetetrarpg.x10.mx/usercard/?name=muppetds

Offline

 

#140 2012-02-28 13:25:15

GameHutSoftware
Scratcher
Registered: 2010-04-24
Posts: 1000+

Re: Java Official Topic

poopo wrote:

GameHutSoftware wrote:

does anyone know how to make something wait until a button is pressed?
ive tried making a loop raise a bogus variable (1) until a different variable (2) is a certain number

the button changes the other variable (2) by one but only if the variable (2) is 0

but it just gets unhappy and freezes and turns black

boolean mybuttonpressed = false
While(!mybuttonpressed){
}
public void keyPressed(KeyEvent ke)
{
    if(ke.keyText(ke.keyCode) == "space")
        mybuttonpressed = true;
}
sloppy and unterminatable but it works.

not a key
a jButton


Lurking more than posting, but still here.

Offline

 

#141 2012-02-28 13:39:48

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Java Official Topic

GameHutSoftware wrote:

poopo wrote:

GameHutSoftware wrote:

does anyone know how to make something wait until a button is pressed?
ive tried making a loop raise a bogus variable (1) until a different variable (2) is a certain number

the button changes the other variable (2) by one but only if the variable (2) is 0

but it just gets unhappy and freezes and turns black

boolean mybuttonpressed = false
While(!mybuttonpressed){
}
public void keyPressed(KeyEvent ke)
{
    if(ke.keyText(ke.keyCode) == "space")
        mybuttonpressed = true;
}
sloppy and unterminatable but it works.

not a key
a jButton

Code:

        JButton button = new JButton("Click This Button");
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e){
                //Execute when button is pressed
            }
        });

That should work...

Last edited by ProgrammingFreak (2012-02-28 13:40:04)

Offline

 

#142 2012-02-28 14:45:32

TRocket
Scratcher
Registered: 2009-08-18
Posts: 1000+

Re: Java Official Topic

ProgrammingFreak wrote:

wmays wrote:

Just wondering, but is it possible to define methods like for? Sort of like this...

Code:

repeat(10) {
//code to be executed
}

Is there a way to define the repeat(){} method? I'm making a library for scratch users who want to learn java... it will be like Scratch (sorta).

I'm thinking this kind of code? (I'm still learning  tongue  )

Code:

static void repeat(int num) {
     for (int i = 0; i < num; i++) {
     }  
}

it could be made simpler like this(using an anonymous inner class)

Code:

repeat(3, new code() {public void code() {
            
        }});

the repeat method:

Code:

public static void repeat(int num, code code){
    for (int i = 0; i < num; i++) {
        code.code();
    }
}

code.java

Code:

public interface code {

    public void code();
    
}

http://i.imgur.com/1QqnHxQ.png

Offline

 

#143 2012-02-28 14:54:20

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Java Official Topic

TRocket wrote:

ProgrammingFreak wrote:

wmays wrote:

Just wondering, but is it possible to define methods like for? Sort of like this...

Code:

repeat(10) {
//code to be executed
}

Is there a way to define the repeat(){} method? I'm making a library for scratch users who want to learn java... it will be like Scratch (sorta).

I'm thinking this kind of code? (I'm still learning  tongue  )

Code:

static void repeat(int num) {
     for (int i = 0; i < num; i++) {
     }  
}

it could be made simpler like this(using an anonymous inner class)

Code:

repeat(3, new code() {public void code() {
            
        }});

the repeat method:

Code:

public static void repeat(int num, code code){
    for (int i = 0; i < num; i++) {
        code.code();
    }
}

code.java

Code:

public interface code {

    public void code();
    
}

Yeah, I said that later in the thread.  tongue
But this looks good.  big_smile

Offline

 

#144 2012-02-28 17:29:26

poopo
Scratcher
Registered: 2009-09-20
Posts: 1000+

Re: Java Official Topic

I successfully made a draggable easily editable scratch type block in java.  smile


http://i45.tinypic.com/28rnqki.jpg

Offline

 

#145 2012-02-28 18:31:34

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Java Official Topic

poopo wrote:

I successfully made a draggable easily editable scratch type block in java.  smile

Cool.

Offline

 

#146 2012-02-28 18:38:08

16Skittles
Scratcher
Registered: 2009-08-26
Posts: 1000+

Re: Java Official Topic

I am happy to announce releasing Pong as my first java game! You can read more on my Tumblr here. It's quite amazing that I've completed my first game exactly one month from my first compiled java project. If you look at the tumblr, I was able to compile on February 2nd and am releasing the finished product of all that work on February 29th!


http://16skittles.tk/sig.png
Are you a student? Check out OnSchedule!

Offline

 

#147 2012-02-28 23:35:22

ihaveamac
Scratcher
Registered: 2007-09-22
Posts: 1000+

Re: Java Official Topic

Anyone know what I could use to make a GUI in java?


~ihaveamac - visit ihaveamac.net

Offline

 

#148 2012-02-29 00:19:04

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Java Official Topic

ihaveamac wrote:

Anyone know what I could use to make a GUI in java?

Use the javax.swing toolkit. Obviously that's a lot of classes, so here're some guides to hopefully help you along:

Oracle's Swing GUI guide
Thenewboston's tutorial You'll have to watch several videos - he uses quite a few to go over the basics. However, he's very good at explaining things in the simplest way possible if that's what you need.


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#149 2012-02-29 09:46:39

16Skittles
Scratcher
Registered: 2009-08-26
Posts: 1000+

Re: Java Official Topic

It's here! ALLCAPSRAGE'S first Undercover Study Hall Update! This happens to be the first release of our Pong remake! You can download the .zip file here

In this release:

A functional Pong game
All required files to run Pong
    pong.jar
    lwjgl.jar and swing.jar (util libraries)
    LWJGL required DLL's
    Images (inside pong.jar)
    Java source code (in the source folder)

Single player with AI opponent
Scorekeeping


To run Pong, unzip the folder and double-click pong.jar!


http://16skittles.tk/sig.png
Are you a student? Check out OnSchedule!

Offline

 

#150 2012-02-29 09:58:57

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Java Official Topic

Nice 16, that's great for a first game :3


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

Board footer