Simulated OS With Canvas
May 5, 2015
I have to build a simulated OS for my college class. I'm making it pretty simple, nothing too fancy and am using HTML5 Canvas. So far I have the icons on a black background and have made them draggable. I want to know how I can make it so when you click on an icon a box appears (just like a real OS) and then closes by clicking on the 'x'. I also want to be able to drag any icon into the trash bin and it disappears. I understand there are click/mouse events, but I don't know how to implement them into the code I have setup. Here's the code:
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<div id="canvas"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/kineticjs/5.2.0/kinetic.js"></script>
<script defer="defer">
var stage = new Kinetic.Stage({
container: 'canvas',
width: 1910,
height: 995,
[Code] ....
View Replies
Feb 11, 2014
I and a friend are working with a project to create a file system, who manages a secondary memory simulated as a byte array in Java. We want the file system to be a hierarchical tree structure like in UNIX.
We have come quite far, but the paths are not handled correct. I seem to have mistaken the relative folder ./ for the root folder, but it should mean "working directory folder", ie, where I stand now. That is, if I stand in /dir1 as my "working directory" and make mkdir ./dir2 then should dir2 end up as subfolder in dir1. But with me it appears in the root.
View Replies
View Related
Apr 10, 2014
Java Code:
public class Game extends Canvas implements Runnable, KeyListener {
private static final long serialVersionUID = 1L;
public Game() {
setMinimumSize(new Dimension(width, height));
setMaximumSize(new Dimension(width, height));
setPreferredSize(new Dimension(width, height));
}
[code]...
I want to remove the extends Canvas from the top line and when I use JFrame to add canvas, I don't do add.(this, but instead I do add a canvas variable I make. So instead of extending I want to make a variable. But then how would I do the start, stop and run?I want to use Graphics, Canvas (Not Jpanel because I want to use BufferedImage) & JFrame. I don't want to extend Canvas, how could I use Canvas identically to shown above but instead of extending using it as a variable? or, how could I do this?
View Replies
View Related
Jun 21, 2014
I'm currently having trouble with a Breakout clone that I'm working on when I want to change the scenes of the game. When I start out with the main menu and I hit play, the main menu calls for the StateManager to remove the MainMenu and then to add the GameState to start playing through the levels. But, whenever this is done it just gives a NullPointerException and freezes the game. I know the code for initially starting a State is fine because that is the same way the MainMenu is loaded but there seems to be an issue with changing from one to another...
This is the StateManager class that adds and removes the States/Canvases to and from the JFrame/Main class:
public class StateManager
{
private ArrayList<State> states;
private int currentState;
private JFrame gameFrame;
public StateManager(JFrame gameFrame)
{
this.gameFrame = gameFrame;
states = new ArrayList<State>();
[Code] ....
I've tried messing around with the order of which things are added/loading from the StateManager but am just failing to see what I did wrong.
View Replies
View Related
Jun 22, 2014
I'm currently having trouble with a Breakout clone that I'm working on when I want to change the scenes of the game. When I start out with the main menu and I hit play, the main menu calls for the StateManager to remove the MainMenu and then to add the GameState to start playing through the levels. But, whenever this is done it just gives a NullPointerException and freezes the game. I know the code for initially starting a State is fine because that is the same way the MainMenu is loaded but there seems to be an issue with changing from one to another...
This is the StateManager class that adds and removes the States/Canvases to and from the JFrame/Main class:
package com.pathtocreating.Breakout_V2.state;
import java.awt.BorderLayout;
import java.util.ArrayList;
import javax.swing.JFrame;
public class StateManager {
private ArrayList<State> states;
[Code] ....
The code that calls the change of state in MainMenuState is called in the update method:
if(inputController.isMouseClicked("LeftClick")) {
if(playHover) {
soundManager.playSound("ButtonClick");
BreakoutMain.sm.changeStates("GameState");
[Code] ....
Here is the full stack trace when clicking the area to change states:
Exception in thread "Thread-2" java.lang.NullPointerException
at sun.java2d.SunGraphics2D.validateColor(Unknown Source)
at sun.java2d.SunGraphics2D.<init>(Unknown Source)
at sun.awt.image.SunVolatileImage.createGraphics(Unknown Source)
[Code] ...
It gives that same value both before and after clicking on the region.
Printing out b after the State is changed to GameState gives the following:
java.awt.Component$BltSubRegionBufferStrategy@66116674
I've tried messing around with the order of which things are added/loading from the StateManager but am just failing to see what I did wrong.
View Replies
View Related
Feb 25, 2015
I want to create off-screen images by Canvases in multi-thread environment.
I know that I use methods of GraphicsContext2D to draw on Canvas. Can I do this on Canvas which is not added to Scene ?
How can I get an image from a canvas after I invoke GraphicsContext2D methods? Can I get images in multi-thread environment ?
View Replies
View Related