ok
Offline
just for info i did google how to do this and did as it said I AM JUST LEARNING I DONT KNOW EVERYTHING
Offline
no other people wanted to i just wanted to tag along and help were i can but mostly i would lie to learn from others
Offline
poopo wrote:
ProgrammingFreak wrote:
poopo wrote:
Me too and that is why I LOVE netbeans go feature!
Netbeans is extremely slow for me.
I might switch to Eclipse cause it also has Android plugins.Do you have lots of plugins?
I've never tried Eclipse.
None.
Offline
wmays wrote:
I can write some of the sprite drawing stuff. The only thing I don't know how to do is the speech bubbles and thought bubbles. It would involve some concurrency to get rid of flickering and low frame rate.
BufferedImage Object.
I'll work on some boolean blocks.
Offline
poopo
i tried fixing up the code but it keeps coming up with errors - cannot find symbol
EDIT: I know that you have to import something but what?
import com.sun.tools.internal.ws.processor.model.Block; import java.awt.*; class scratchjava{ Block block = new Block("My block", Color.blue, 30,30); private Color gray; private boolean change; private Color black; private int mouseY; private boolean mouseDownLastTime; private int x; private int y; public void paint(Graphics g, FontMetrics fm) { Graphics2D g2D = (Graphics2D) g; g2D.setColor(gray); if (change) g2D.fillRect(0, 0, jf.getWidth(), jf.getHeight()); fm = g.getFontMetrics(g2D.getFont()); g2D.setColor(block.blockColor); g2D.fillRoundRect(block.blockX, block.blockY, 10 + fm.stringWidth(block.blockText), 25, 5, 5); g2D.fillRect(block.blockX + 10, block.blockY + 25, 20, 5); g2D.setColor(gray); g2D.fillRect(block.blockX + 10, block.blockY, 20, 5); g2D.setColor(black); g2D.drawString(block.blockText, block.blockX + 5, block.blockY + 19); UpdateBlock(fm.stringWidth(block.blockText), block); } private void UpdateBlock(int blockLength, Block block, int mouseX){ change = false; mouseX = MouseInfo.getPointerInfo().getLocation().x - jf.getX(); mouseY = MouseInfo.getPointerInfo().getLocation().y - jf.getY(); blockClicked(mouseX, mouseY, block.blockX,block.blockY,blockLength + 10, mouseDown); repaint(); } public void blockClicked(int mouseX, int mouseY, int blockX, int blockY, int blockLength , boolean mouseDown){ if (mouseDown){ if((blockX <= mouseX & (blockX + blockLength) >= mouseX & blockY <= mouseY & (blockY + 25) >= mouseY) || mouseDownLastTime){ mouseDownLastTime = true; x = mouseX - (blockLength / 2); y = mouseY - 42; change = true; } } else { mouseDownLastTime = false; } } private void repaint() { throw new UnsupportedOperationException("Not yet implemented"); } }
Last edited by muppetds (2012-03-18 13:13:34)
Offline
muppetds wrote:
poopo
i tried fixing up the code but it keeps coming up with errors - cannot find symbol
EDIT: I know that you have to import something but what?Code:
import com.sun.tools.internal.ws.processor.model.Block; import java.awt.*; class scratchjava{ Block block = new Block("My block", Color.blue, 30,30); private Color gray; private boolean change; private Color black; private int mouseY; private boolean mouseDownLastTime; private int x; private int y; public void paint(Graphics g, FontMetrics fm) { Graphics2D g2D = (Graphics2D) g; g2D.setColor(gray); if (change) g2D.fillRect(0, 0, jf.getWidth(), jf.getHeight()); fm = g.getFontMetrics(g2D.getFont()); g2D.setColor(block.blockColor); g2D.fillRoundRect(block.blockX, block.blockY, 10 + fm.stringWidth(block.blockText), 25, 5, 5); g2D.fillRect(block.blockX + 10, block.blockY + 25, 20, 5); g2D.setColor(gray); g2D.fillRect(block.blockX + 10, block.blockY, 20, 5); g2D.setColor(black); g2D.drawString(block.blockText, block.blockX + 5, block.blockY + 19); UpdateBlock(fm.stringWidth(block.blockText), block); } private void UpdateBlock(int blockLength, Block block, int mouseX){ change = false; mouseX = MouseInfo.getPointerInfo().getLocation().x - jf.getX(); mouseY = MouseInfo.getPointerInfo().getLocation().y - jf.getY(); blockClicked(mouseX, mouseY, block.blockX,block.blockY,blockLength + 10, mouseDown); repaint(); } public void blockClicked(int mouseX, int mouseY, int blockX, int blockY, int blockLength , boolean mouseDown){ if (mouseDown){ if((blockX <= mouseX & (blockX + blockLength) >= mouseX & blockY <= mouseY & (blockY + 25) >= mouseY) || mouseDownLastTime){ mouseDownLastTime = true; x = mouseX - (blockLength / 2); y = mouseY - 42; change = true; } } else { mouseDownLastTime = false; } } private void repaint() { throw new UnsupportedOperationException("Not yet implemented"); } }
I didn't happen to also share my code for Block.java. Also it needs to extend from JPanel, and there needs to be a JFrame name jf. Then you have to add jf.add(this); to the constructor. I'll see if I can fix it up enough to be run able.
Last edited by poopo (2012-03-18 13:20:15)
Offline
poopo wrote:
muppetds wrote:
poopo
i tried fixing up the code but it keeps coming up with errors - cannot find symbol
EDIT: I know that you have to import something but what?Code:
import com.sun.tools.internal.ws.processor.model.Block; import java.awt.*; class scratchjava{ Block block = new Block("My block", Color.blue, 30,30); private Color gray; private boolean change; private Color black; private int mouseY; private boolean mouseDownLastTime; private int x; private int y; public void paint(Graphics g, FontMetrics fm) { Graphics2D g2D = (Graphics2D) g; g2D.setColor(gray); if (change) g2D.fillRect(0, 0, jf.getWidth(), jf.getHeight()); fm = g.getFontMetrics(g2D.getFont()); g2D.setColor(block.blockColor); g2D.fillRoundRect(block.blockX, block.blockY, 10 + fm.stringWidth(block.blockText), 25, 5, 5); g2D.fillRect(block.blockX + 10, block.blockY + 25, 20, 5); g2D.setColor(gray); g2D.fillRect(block.blockX + 10, block.blockY, 20, 5); g2D.setColor(black); g2D.drawString(block.blockText, block.blockX + 5, block.blockY + 19); UpdateBlock(fm.stringWidth(block.blockText), block); } private void UpdateBlock(int blockLength, Block block, int mouseX){ change = false; mouseX = MouseInfo.getPointerInfo().getLocation().x - jf.getX(); mouseY = MouseInfo.getPointerInfo().getLocation().y - jf.getY(); blockClicked(mouseX, mouseY, block.blockX,block.blockY,blockLength + 10, mouseDown); repaint(); } public void blockClicked(int mouseX, int mouseY, int blockX, int blockY, int blockLength , boolean mouseDown){ if (mouseDown){ if((blockX <= mouseX & (blockX + blockLength) >= mouseX & blockY <= mouseY & (blockY + 25) >= mouseY) || mouseDownLastTime){ mouseDownLastTime = true; x = mouseX - (blockLength / 2); y = mouseY - 42; change = true; } } else { mouseDownLastTime = false; } } private void repaint() { throw new UnsupportedOperationException("Not yet implemented"); } }I didn't happen to also share my code for Block.java. Also it needs to extend from JPanel, and there needs to be a JFrame name jf. Then you have to add jf.add(this); to the constructor. I'll see if I can fix it up enough to be run able.
lol if you use netbeans give the project files please
Offline
MainIDE.java:
import java.awt.*; import javax.swing.*; public class MainIDE extends JPanel { JFrame jf = new JFrame("ScratchJava"); Image frameImage = new ImageIcon(getClass().getResource("Images/Icon.gif")).getImage(); Color black = Color.black; Color gray = Color.gray; Color blue = Color.blue; FontMetrics fm; int mouseX = MouseInfo.getPointerInfo().getLocation().x; int mouseY = MouseInfo.getPointerInfo().getLocation().y; int ssX = Toolkit.getDefaultToolkit().getScreenSize().width; int ssY = Toolkit.getDefaultToolkit().getScreenSize().height; int x = 30; int y = 30; MouseInput mi = new MouseInput(this); public static boolean change = false; public static boolean beingDragged = false; boolean mouseDownLastTime = false; TextOnlyBlock block = new TextOnlyBlock("hello",22,22,blue); public MainIDE() { jf.setIconImage(frameImage); jf.setSize(ssX, ssY); jf.setDefaultCloseOperation(3); jf.add(this); jf.setVisible(true); jf.setBackground(gray); } public void paint(Graphics g) { Graphics2D g2D = (Graphics2D) g; g2D.setColor(gray); if (change) g2D.fillRect(0, 0, jf.getWidth(), jf.getHeight()); fm = g.getFontMetrics(g2D.getFont()); g2D.setColor(block.blockColor); g2D.fillRoundRect(block.blockX, block.blockY, 10 + fm.stringWidth(block.blockText), 25, 5, 5); g2D.fillRect(block.blockX + 10, block.blockY + 25, 20, 5); g2D.setColor(gray); g2D.fillRect(block.blockX + 10, block.blockY, 20, 5); g2D.setColor(black); g2D.drawString(block.blockText, block.blockX + 5, block.blockY + 19); UpdateBlock(fm.stringWidth(block.blockText), block); } private void UpdateBlock(int blockLength, Block block){ change = false; mouseX = MouseInfo.getPointerInfo().getLocation().x - jf.getX(); mouseY = MouseInfo.getPointerInfo().getLocation().y - jf.getY(); block.blockClicked(mouseX, mouseY, blockLength + 10, mi.mouseDown1); repaint(); } public void blockClicked(int mouseX, int mouseY, int blockX, int blockY, int blockLength , boolean mouseDown){ if (mouseDown){ if((blockX <= mouseX & (blockX + blockLength) >= mouseX & blockY <= mouseY & (blockY + 25) >= mouseY) || mouseDownLastTime){ mouseDownLastTime = true; x = mouseX - (blockLength / 2); y = mouseY - 42; change = true; } } else { mouseDownLastTime = false; } } public static void main(String[] args) { new MainIDE(); } }
Block.java:
NOTE:An interface may be more effective here but I have little experience working with them
public abstract class Block { public abstract void blockClicked(int mouseX, int mouseY, int blockLength, boolean mouseDown); }
TextOnlyBlock:
import java.awt.*; public class TextOnlyBlock extends Block { boolean mouseDownLastTime = false; boolean mouseDraggingLastTime = false; int blockX; int blockY; String blockText; Font blockFont = new Font(Font.DIALOG, Font.PLAIN, 12); Color blockColor; public TextOnlyBlock(String blockText, int blockX, int blockY, Color blockColor) { this.blockX = blockX; this.blockY = blockY; this.blockText = blockText; this.blockColor = blockColor; } public void blockClicked(int mouseX, int mouseY, int blockLength, boolean mouseDown){ if (mouseDown){ if(((blockX <= mouseX & (blockX + blockLength) >= mouseX & blockY <= mouseY & (blockY + 25) >= mouseY) || mouseDownLastTime) & (!MainIDE.beingDragged || mouseDraggingLastTime)){ mouseDownLastTime = true; mouseDraggingLastTime = true; this.blockX = mouseX - (blockLength / 2); this.blockY = mouseY - 42; MainIDE.beingDragged = true; MainIDE.change = true; } } else { if(mouseDraggingLastTime == true) MainIDE.beingDragged = false; mouseDownLastTime = false; } } }
MouseInput.java:
import java.awt.event.*; import javax.swing.*; public class MouseInput implements MouseMotionListener, MouseListener { boolean mouseDown1 = false; boolean mouseDown2 = false; JPanel jp; public MouseInput(JPanel jp){ this.jp = jp; this.jp.addMouseMotionListener(this); this.jp.addMouseListener(this); } public void mouseExited(MouseEvent me){ } public void mouseEntered(MouseEvent me){ } public void mouseReleased(MouseEvent me){ mouseDown1 = false; } public void mousePressed(MouseEvent me){ mouseDown1 = true; } public void mouseClicked(MouseEvent me){ } public void mouseDragged(MouseEvent me){ } public void mouseMoved(MouseEvent me){ } }
And there it is. If you have any trouble give me the error report.
To drag the block click above it, for some reason it's a bit faulty
Last edited by poopo (2012-03-18 13:32:55)
Offline
I fixed the above error
now this is the debug when i try and run it
Deleting: /Volumes/Macintosh HD 2/matthew/NetBeansProjects/Scratch Java/build/built-jar.properties deps-jar: Updating property file: /Volumes/Macintosh HD 2/matthew/NetBeansProjects/Scratch Java/build/built-jar.properties Compiling 3 source files to /Volumes/Macintosh HD 2/matthew/NetBeansProjects/Scratch Java/build/classes /Volumes/Macintosh HD 2/matthew/NetBeansProjects/Scratch Java/src/MainIDE.java:82: cannot find symbol symbol : variable MainIDE location: class MainIDE MainIDE = new MainIDE(); /Volumes/Macintosh HD 2/matthew/NetBeansProjects/Scratch Java/src/TextOnlyBlock.java:29: cannot find symbol symbol : variable MainIde location: class TextOnlyBlock & (!MainIde.beingDragged || mouseDraggingLastTime)){ 2 errors /Volumes/Macintosh HD 2/matthew/NetBeansProjects/Scratch Java/nbproject/build-impl.xml:605: The following error occurred while executing this line: /Volumes/Macintosh HD 2/matthew/NetBeansProjects/Scratch Java/nbproject/build-impl.xml:246: Compile failed; see the compiler error output for details. BUILD FAILED (total time: 0 seconds)
Offline
muppetds wrote:
I fixed the above error
now this is the debug when i try and run itCode:
Deleting: /Volumes/Macintosh HD 2/matthew/NetBeansProjects/Scratch Java/build/built-jar.properties deps-jar: Updating property file: /Volumes/Macintosh HD 2/matthew/NetBeansProjects/Scratch Java/build/built-jar.properties Compiling 3 source files to /Volumes/Macintosh HD 2/matthew/NetBeansProjects/Scratch Java/build/classes /Volumes/Macintosh HD 2/matthew/NetBeansProjects/Scratch Java/src/MainIDE.java:82: cannot find symbol symbol : variable MainIDE location: class MainIDE MainIDE = new MainIDE(); /Volumes/Macintosh HD 2/matthew/NetBeansProjects/Scratch Java/src/TextOnlyBlock.java:29: cannot find symbol symbol : variable MainIde location: class TextOnlyBlock & (!MainIde.beingDragged || mouseDraggingLastTime)){ 2 errors /Volumes/Macintosh HD 2/matthew/NetBeansProjects/Scratch Java/nbproject/build-impl.xml:605: The following error occurred while executing this line: /Volumes/Macintosh HD 2/matthew/NetBeansProjects/Scratch Java/nbproject/build-impl.xml:246: Compile failed; see the compiler error output for details. BUILD FAILED (total time: 0 seconds)
-_-' MainIDE = new MainIDE(); doesn't work it needs a variable name. just do new MainIDE();
Last edited by poopo (2012-03-18 13:53:55)
Offline
it ran then quit:
Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(ImageIcon.java:181)
at MainIDE.<init>(MainIDE.java:10)
at MainIDE.main(MainIDE.java:82)
Java Result: 1
Offline
muppetds wrote:
it ran then quit:
Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(ImageIcon.java:181)
at MainIDE.<init>(MainIDE.java:10)
at MainIDE.main(MainIDE.java:82)
Java Result: 1
Oh oops you need the frame Image for that. Delete all the lines containing frameImage in MainIDE
Offline