generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Java Challenge - Project 1 (Repost)

Previous Thread :: Next Thread 
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
30 Oct 2012 11:59 PM
[ Content Deleted ]
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
31 Oct 2012 12:04 AM
Erm, I really need to focus on Java and forget RBX.Lua, I know you need some scanner thing.

deathCast();
Report Abuse
Riderj is not online. Riderj
Joined: 15 Aug 2011
Total Posts: 1534
31 Oct 2012 12:06 AM
No! Don't ever give up on a language. Each language builds on how well you can understand the next.
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
31 Oct 2012 12:08 AM
Well, it's kind of impossible for me to forget RBX.Lua

deathCast();
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
31 Oct 2012 12:17 AM
Are either of you going to try it?
Report Abuse
Riderj is not online. Riderj
Joined: 15 Aug 2011
Total Posts: 1534
31 Oct 2012 12:19 AM
I'm looking at it, still working on reading what a magic square is.
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
31 Oct 2012 12:19 AM
Too bad I only know C++ and RBX.Lua

#include < iostream> //I used a space because of stupid roblox
#inclue < string>

using namespace std;

int main()
{
cout << "What's your name?"
string name
cin >> name
cout << "Hello, " << name << "!"
}

I'm a bit rusty on C++
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
31 Oct 2012 12:19 AM
Took me about 45 minutes to post this. Apparently 'magic square' in caps is against Roblox rules ....
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
31 Oct 2012 12:19 AM
Wait, this is printing? Not JFrame then buttons and JLables

deathCast();
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
31 Oct 2012 12:20 AM
MAGIC SQUARE

deathCast();
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
31 Oct 2012 12:20 AM
Correct. I'll be using an auto grader (made by yours truly) to grade these projects.
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
31 Oct 2012 12:21 AM
Could anyone who knows a bit of C++ fix my code?
Report Abuse
Riderj is not online. Riderj
Joined: 15 Aug 2011
Total Posts: 1534
31 Oct 2012 12:21 AM
I'm stumped >.<
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
31 Oct 2012 12:25 AM
How do you finish the puzzle? What do you do?

deathCast();
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
31 Oct 2012 12:27 AM
Nevermind, I googled it like the instructions said,

deathCast();
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
31 Oct 2012 12:29 AM
Does it have to be 5x5? e.e

deathCast();
Report Abuse
Riderj is not online. Riderj
Joined: 15 Aug 2011
Total Posts: 1534
31 Oct 2012 12:31 AM
Has to be Dynamic meaning whatever size it put into it.
Report Abuse
Riderj is not online. Riderj
Joined: 15 Aug 2011
Total Posts: 1534
31 Oct 2012 12:42 AM
0 1 2 3 4 5

1

2

3

4

5


Have that basic Part down :P (Note: Roblox messed up the spacing)
Report Abuse
Greyhound40 is not online. Greyhound40
Joined: 15 Oct 2008
Total Posts: 933
31 Oct 2012 05:27 AM
package zetcode;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.CropImageFilter;
import java.awt.image.FilteredImageSource;

import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class Puzzle extends JFrame implements ActionListener {

private JPanel centerPanel;
private JButton button;
private JLabel label;
private Image source;
private Image image;
int[][] pos;
int width, height;

public Puzzle() {

initUI();
}

public final void initUI() {

pos = new int[][]{
{0, 1, 2},
{3, 4, 5},
{6, 7, 8},
{9, 10, 11}
};


centerPanel = new JPanel();
centerPanel.setLayout(new GridLayout(4, 4, 0, 0));

ImageIcon sid = new ImageIcon(Puzzle.class.getResource("icesid.jpg"));
source = sid.getImage();

width = sid.getIconWidth();
height = sid.getIconHeight();


add(Box.createRigidArea(new Dimension(0, 5)), BorderLayout.NORTH);
add(centerPanel, BorderLayout.CENTER);


for (int i = 0; i < 4; i++) {
for (int j = 0; j < 3; j++) {
if (j == 2 && i == 3) {
label = new JLabel("");
centerPanel.add(label);
} else {
button = new JButton();
button.addActionListener(this);
centerPanel.add(button);
image = createImage(new FilteredImageSource(source.getSource(),
new CropImageFilter(j * width / 3, i * height / 4,
(width / 3) + 1, height / 4)));
button.setIcon(new ImageIcon(image));
}
}
}

setSize(325, 275);
setTitle("Puzzle");
setResizable(false);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}

public void actionPerformed(ActionEvent e) {

JButton button = (JButton) e.getSource();
Dimension size = button.getSize();

int labelX = label.getX();
int labelY = label.getY();
int buttonX = button.getX();
int buttonY = button.getY();
int buttonPosX = buttonX / size.width;
int buttonPosY = buttonY / size.height;
int buttonIndex = pos[buttonPosY][buttonPosX];



if (labelX == buttonX && (labelY - buttonY) == size.height) {

int labelIndex = buttonIndex + 3;

centerPanel.remove(buttonIndex);
centerPanel.add(label, buttonIndex);
centerPanel.add(button, labelIndex);
centerPanel.validate();
}

if (labelX == buttonX && (labelY - buttonY) == -size.height) {

int labelIndex = buttonIndex - 3;
centerPanel.remove(labelIndex);
centerPanel.add(button, labelIndex);
centerPanel.add(label, buttonIndex);
centerPanel.validate();
}

if (labelY == buttonY && (labelX - buttonX) == size.width) {

int labelIndex = buttonIndex + 1;

centerPanel.remove(buttonIndex);
centerPanel.add(label, buttonIndex);
centerPanel.add(button, labelIndex);
centerPanel.validate();
}

if (labelY == buttonY && (labelX - buttonX) == -size.width) {

int labelIndex = buttonIndex - 1;

centerPanel.remove(buttonIndex);
centerPanel.add(label, labelIndex);
centerPanel.add(button, labelIndex);
centerPanel.validate();
}
}

public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {

public void run() {
Puzzle puzzle = new Puzzle();
puzzle.setVisible(true);
}
});
}
}
Report Abuse
Greyhound40 is not online. Greyhound40
Joined: 15 Oct 2008
Total Posts: 933
31 Oct 2012 05:29 AM
Ta da :D
Report Abuse
Greyhound40 is not online. Greyhound40
Joined: 15 Oct 2008
Total Posts: 933
31 Oct 2012 05:31 AM
It's funny how:
1) it doesn't work
2) i didn't make it

:c
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
31 Oct 2012 06:25 AM
http://www.roblox.com/Magicsquares-item?id=71269484

that what you mean by magic squares?
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
31 Oct 2012 07:39 AM
@death you're forgetting your semicolons.
I'm not going to participate in this event, since I don't know what flow is, and I don't want to make a puzzle.

I did however make a Tic Tac Toe game in Java last week :3
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
31 Oct 2012 09:23 AM
Of course I would do that, as always

#include < iostream> //I used a space because of stupid roblox
#inclue < string>

using namespace std;

int main()
{
cout << "What's your name?"
string name;
cin >> name;
cout << "Hello, " << name << "!"
}

Better?
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
31 Oct 2012 10:06 AM
Please do not spam my thread with unrelated code/discussion.

If you programmed a tic tac toe game, you know program flow.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image