100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Summary game coding $7.99   Add to cart

Summary

Summary game coding

 1 view  0 purchase
  • Course
  • Institution

Game coding is the process of designing, developing, and implementing the code and logic that powers a video game. This involves using programming languages such as C++, Java, or Python, as well as game engines like Unity or Unreal Engine, to create the various systems and components of a game. ...

[Show more]

Preview 2 out of 5  pages

  • March 5, 2023
  • 5
  • 2022/2023
  • Summary
avatar-seller
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class BrickBreaker extends JPanel implements KeyListener,
ActionListener, Runnable {
// movement keys..
static boolean right = false;
static boolean left = false;
// ..............
// variables declaration for ball.................................
int ballx = 160;
int bally = 218;
// variables declaration for ball.................................
// ===============================================================
// variables declaration for bat..................................
int batx = 160;
int baty = 245;
// variables declaration for bat..................................
// ===============================================================
// variables declaration for brick...............................
int brickx = 70;
int bricky = 50;

int brickBreadth = 30;
int brickHeight = 20;
// variables declaration for brick...............................
// ===============================================================
// declaring ball, paddle,bricks
Rectangle Ball = new Rectangle(ballx, bally, 5, 5);
Rectangle Bat = new Rectangle(batx, baty, 40, 5);
// Rectangle Brick;// = new Rectangle(brickx, bricky, 30, 10);
Rectangle[] Brick = new Rectangle[12];

//reverses......==>
int movex = -1;
int movey = -1;
boolean ballFallDown = false;
boolean bricksOver = false;
int count = 0;
String status;

BrickBreaker() {

}

public static void main(String[] args) {
JFrame frame = new JFrame();
BrickBreaker game = new BrickBreaker();

, JButton button = new JButton("restart");
frame.setSize(350, 450);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.add(game);
frame.add(button, BorderLayout.SOUTH);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.setVisible(true);
button.addActionListener(game);

game.addKeyListener(game);
game.setFocusable(true);
Thread t = new Thread(game);
t.start();

}

// declaring ball, paddle,bricks

public void paint(Graphics g) {
g.setColor(Color.LIGHT_GRAY);
g.fillRect(0, 0, 350, 450);
g.setColor(Color.blue);
g.fillOval(Ball.x, Ball.y, Ball.width, Ball.height);
g.setColor(Color.green);
g.fill3DRect(Bat.x, Bat.y, Bat.width, Bat.height, true);
g.setColor(Color.GRAY);
g.fillRect(0, 251, 450, 200);
g.setColor(Color.red);
g.drawRect(0, 0, 343, 250);
for (int i = 0; i < Brick.length; i++) {
if (Brick[i] != null) {
g.fill3DRect(Brick[i].x, Brick[i].y, Brick[i].width,
Brick[i].height, true);
}
}

if (ballFallDown == true || bricksOver == true) {
Font f = new Font("Arial", Font.BOLD, 20);
g.setFont(f);
g.drawString(status, 70, 120);
ballFallDown = false;
bricksOver = false;
}

}

// /...Game Loop...................

// /////////////////// When ball strikes borders......... it

public void run() {

// //////////// =====Creating bricks for the game===>.....
createBricks();
// ===========BRICKS created for the game new ready to use===

// ====================================================

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller rishabhsemwal. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $7.99. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

78861 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$7.99
  • (0)
  Add to cart