Posts

Showing posts from September, 2018

Creating a Blue J Game

     Copy and paste the code in diffrent Classes create a new class and past the code in it      MAIN FOR GRAPHICS 2 CLASS     import javax.swing.JFrame; import javax.swing.JPanel; public class MainForGraphics2 { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(1920,1080); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Board panel = new Board();   frame.add(panel); frame.setVisible(true); } } SNAKE CLASS: public class Snake { // Stores the joints / body part locations for our snake private final int[] x = new int[Board.getAllDots()]; private final int[] y = new int[Board.getAllDots()]; // Stores direction of our snake private boolean movingLeft = false; private boolean movingRight = false; private boolean movingUp = false; private boolean movingDown = false; private int joints = 0; // Stores # of dots / joints the snake has (starts                         //

Python Program For Simple Animation

import time from tkinter import * animation=Tk() Canvas=Canvas(animation , width = 800 , height = 800 ) # it is the windows size you can change it Canvas.pack() Canvas.create_arc( 10 , 10 , 100 , 100 , fill = 'black' ) for x in range ( 0 , 140 ): # don't forget to put ' : ' in the end of the forr loop Canvas.move( 1 , 5 , 0 ) animation.update() time.sleep( 0.05 ) # it is the time taken to move per place for x in range ( 0 , 140 ): Canvas.move( 1 , - 5 , 0 ) animation.update() time.sleep( 0.05 ) for x in range ( 0 , 140 ): Canvas.move( 1 , 5 , 0 ) animation.update() time.sleep( 0.05 ) for x in range ( 0 , 140 ): Canvas.move( 1 , - 5 , 0 ) animation.update() time.sleep( 0.05 )