2d-games

Is it possible to make a ImageView in JavaFX responsive?

♀尐吖头ヾ 提交于 2020-01-25 06:48:27
问题 me and some friends are having a project, where we try to programm a game in JavaFX. We´ve got a GridPane, thats growing with ImageViews inside to hold the map and the game character, etc. (The game character and enemies will have their own imageview, that we can move around in the gridpane.) So, our problem now is, that we want out pictures to get bigger, when the window is getting bigger also, but right now only the columns of the GridPane are getting more distance to each other. I tried to

Adding Start, Stop, Reset button to simple java game

我们两清 提交于 2020-01-20 09:34:25
问题 I am a new coder. I am having trouble adding a start and stop button for this piece of example code that i am working off. I'm sure i have to mess with with Thread.sleep(10); in the game class. This code starts the game when the program is run. is there a way i could add start button to start the thread. I have created j button already. Thanks. Game Class import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.event.KeyEvent; import java.awt.event

Adding Start, Stop, Reset button to simple java game

只愿长相守 提交于 2020-01-20 09:33:42
问题 I am a new coder. I am having trouble adding a start and stop button for this piece of example code that i am working off. I'm sure i have to mess with with Thread.sleep(10); in the game class. This code starts the game when the program is run. is there a way i could add start button to start the thread. I have created j button already. Thanks. Game Class import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.event.KeyEvent; import java.awt.event

Moving character on canvas but not on the screen

微笑、不失礼 提交于 2020-01-07 09:43:27
问题 I am making a 2d game in JavaScript but my character can only move around the length of the screen so I was wondering if there was a way to make the canvas move but my character stay on the middle of the screen could Simone please help me here is my code for the test game <html> <body> <canvas id="canvas"> </canvas> </body> </html> <script> var audio = new Audio('sounds/theServerRoom.mp3'); audio.play(); // Create the canvas var canvas = document.getElementById("canvas"); var context = canvas

How can we stop this HTML5 Canvas wheel at exact points after spin?

ε祈祈猫儿з 提交于 2020-01-06 08:06:15
问题 In the Below code link HTML5 canvas spin wheel game. I want to stop this canvas at a user-defined position as if the user wants to stop always at 200 texts or 100 texts like that. Currently, it is stopping at random points I want to control where to stop as in if I want to stop circle at 100 or 200 or 0 whenever I want. How can we achieve that??? Can anyone Help!!!!! Attached Codepen link also. Html file <div> <canvas class="spin-wheel" id="canvas" width="300" height="300"></canvas> </div> JS

Using Phaser together with React

感情迁移 提交于 2020-01-02 04:33:05
问题 I am trying to understand how I could use React for rendering all the UI elements and Phaser for rendering a game (using Canvas or WebGL) within the React application. One way would be to use React's componentDidMount, so after I have my HTML ready I can use a div id to render the Phaser content. In this case who does the rendering? React of Phaser? If the mentioned way is not the right one, could you suggest another? 回答1: There is a module for this on Github called react-phaser . Here is a

animated background java game

孤者浪人 提交于 2019-12-31 07:16:12
问题 I was programming a game similar to asteroid, but I do not understand how to spawn the asteroids in the background. now i spawn an asteroid in the main class but i want create a class for the asteroid ho i do it? MAIN CLASS public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; if(flag_img) { background(g2d); logo(g2d); menu(g2d); spaceship(g2d); crediti(g2d); } } background function(now) private void background(Graphics2D g2d) { asteroidi_g_x+=r

Metro app Holding event in games

怎甘沉沦 提交于 2019-12-25 05:28:29
问题 I made a game where user navigates a character. Since it is designed for both PC and tablet (with Win8), there are two options how to do it. 1) using keyboard ( Key_Down and Key_Up events) 2) using touch and hold ( Tapped and Holding events) Unfortunately there is a problem with Holding event, because it raises after a long time period (I think 1 sec). I had to use word long there becase it really is a long time period in games. Now, I need a better solution. There is a onscreen joystick in

Processing: How can I color the squares drawn by my 2D Array in different colors?

岁酱吖の 提交于 2019-12-25 05:04:04
问题 I'm trying to make a game board for bomberman in processing with a 2D array. (The final version will have colors or bitmaps and the properties of each block type and will define the walking space that the player has.) I want this game board which consists of 11 rows and 11 columns to have squares of different colors for each block type in the game. ( j being a solid block, i being walking space and k being a breakable block, as you'll see in the array) I've already managed to draw the array

Which design pattern is appropriate for countable objects?

安稳与你 提交于 2019-12-25 03:23:03
问题 I have a problem that I can't solve again. As junior developer that have recently got acquainted with design patterns and doesn't deal with them yet, I need your help to find appropriate. The issue is: I want to generalize objects with help of an abstract class or interface. I want to count every instance of derived class, because I need to limit their number. For example in "Sea Battle" game I use classes: SeaObject ----> Mine, Boat, Kreyser. The quantity of mines,boats,etc are limited I