'Java Programming Tutorial' | 'Super Mario Game' #8 | Graphics and BufferStrategies

preview_player
Показать описание
Welcome to episode 8 of our mario game in java programming tutorial. This episode, we create bufferstrategies and colour in our frame with whatever colour we want.

Episode 9 will be out next Thursday. Anyway, if you enjoyed the video, leave a like, a comment, and subscribe!

Intro Music: Knife Party - Centipede
Outro Music: K-391 ft. Gjermund Olstad - Hang Loose

Stay tuned for more! :)
Рекомендации по теме
Комментарии
Автор

Never been so excited about an empty screen of magenta.

jackmiddleton
Автор

Exception in thread "Thread" java.lang.Error: Unresolved compilation problem:
BufferStrategy cannot be resolved to a type

at
at
at

patrickengels
Автор

im getting an error
Source)
on the line
createBufferStrategy(3)

eliholst
Автор

hey man another problem here i cant seem to get the color to appear her and words of advice you can give me it keeps saying the Color isnt a type


public void render(){
BufferStrategy bs = getBufferStrategy();
if(bs==null){
createBufferStrategy(3);
return;
}
Graphics g = bs.getDrawGraphics();
g.setColor(Color.BLACK);
g.fillRect(0, 0, getWidth(), getHeight());
g.dispose();
bs.show();

chrislopez
Автор

Please, I have a question, I have fully implemented the program, but I have a problem with the background color it does not appear. What is the solution?

daniahal
Автор

I want to ask something about your video in 1:01, the frame is still more than 30 but in 6:11, the frame already drop until below 30.

the question is why in my place the frame is still more than 100k, how to drop it until around 30?

thanks

ideerena
Автор

I asked you because just like in HTML5 programming language you have to type line in which you're adding/importing graphics when you drawed your first sprite of character it's looking like you compiled application and it's looking like Ms paint application written in java programming language no offense, but I want to be sure when I'm watching your tutorial that I won't miss some code line.

lukegamerzw
Автор

Why not create a superclass Renderable and inherit the implemantation for Tile and Entity from it, since the implementation is the same?

johanneselseberg
Автор

PLEASE NEED FIX!!! nexxt to my BufferStrategy bs = getBufferStrategy(); THERE IS A RED ARROW THAT SAYS IT WONT WORK, I DONT KNOW WHAT I DID WRONG???

erfanhosseini
Автор

1:33 Well I tought it will be real at least 8-bit sprites of Mario I guess it was changed to avoid copyright infridgement, right?Anyway still interesting tutorial.

lukegamerzw
Автор

Hey ... I followed all your steps, but I don't see any activity on the screen - No changing colors, or the debugging(from the prev ep) of The frames and Updates per second ... Would really Appreciate some help :)
Thanks XD

akhilkumar
Автор

Hey, thanks for the amazing tutorials. Also, it would be great if you could upload the final source code to GitHub, for reference. Thanks. :)

theoraclev
Автор

btw i love ur vids, thanks for sharing your knowledge, good work!(although i'm still trying to fix my code)hahaha

happyjoolife
Автор

How did you learn all these stuff? I want to know if you learned from watching videos or by reading books and what books did you read?

joguland
Автор

Can u use sprites to do the background?

kurtisknodel
Автор

Sir my application well running before applying this tutorial, now application running is so much slow that i cant do anything before closing it

muhammadsaifullahmuhammadj
Автор

public Game(){
Dimension size=Dimension (WIDTH*SCALE, HEIGHT*SCALE);
setPreferredSize(size);
setMaximumSize(size);
setMinimumSize(size);
}
at first the dimension went red..then... this also went red

stop();
}

public void render(){
BufferStrategy bs = getBufferStrategy();

}
public void update(){
my full code:
package com.tutorial.mario;

import java.awt.Canvas;

import javax.swing.JFrame;

public class Game extends Canvas implements Runnable{
public static final int WIDTH=270;
public static final int HEIGHT=WIDTH/10*14;
public static final int SCALE=4;
public static final String TITLE="Mario";

private Thread thread;
private boolean running=false;

public Game(){
Dimension size=Dimension (WIDTH*SCALE, HEIGHT*SCALE);
setPreferredSize(size);
setMaximumSize(size);
setMinimumSize(size);
}
public synchronized void start(){
if(running)return;
running=true;
thread=new Thread(this, "Thread");
System.out.println("abcd");
}
public synchronized void stop(){
if(!running)return;
running=false;
try{
thread.join();
}catch(InterruptedException e){
e.printStackTrace();
}
}
public void run() {
long lastTime=System.nanoTime();
long
double delta=0.0;
double
int frames=0;
int updates=0;
//long now=System.nanoTime();
//output: took 4000ns to go from last time to now
while(running){
long now =System.nanoTime();
delta+=(now-lastTime)/ns;
// doesn't work, add "delta= frames+ticks" in next line for it to work
lastTime =now ;
while(delta>=1){
update();
updates++;//to show +1
delta--;
}
render();
frames++;

timer+=1000;
System.out.println(frames + " Frames Per Second " + updates + " Updates Per Second " );
frames=0;
updates=0;
}
}
stop();
}

public void render(){
BufferStrategy bs = getBufferStrategy();
if (bs==null){
createBufferStrategy(3);
return;
}
Graphics g= bs.getDrawGraphics();
g.setColor(new Color(124, 28, 97));
g.fillRect(0, 0, getWidth(), getHeight()));
g.dispose();
bs.show ();
public void update(){

}

}
public static void main(String[] args){
Game game=new Game();
JFrame frame= new JFrame(TITLE);
frame.add(game);
frame.pack();
frame.setResizable(false);


frame.setVisible(true);
game.start();
}

}

happyjoolife