U3F1ZWV6ZTE4Njk5NTM2MjU3MDQwX0ZyZWUxMTc5NzI4NDQzNTgwOQ==

Programing games using java 4

الدرس الرابع من تصميم لعبة سوبر ماريو 


 السلام عليكم في الفيديو رقم أربعة ، سأستمر في بناء لعبة سوبر ماريو باستخدام لغة جافا.


  سأحاول في هذا الفيديو حل المشكلة المتعلقة بصورة خلفية لعبة سوبر ماريو.


كان في الفيديو الأخير عندما تحرك سوبر ماريو الخلفية لا تزال لا ترسم مرة أخرى عندما يصل سوبر ماريو إلى نهاية 


الخلفية.


من فضلك شاهد الفيديو ولا تنسى الاشتراك ومشاركة الفيديو مع اصدقائك



هذا هو الكود الذي نستخدمه في هذا الفيديو

package websit.supermario;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public class Scene extends JPanel {
	private ImageIcon icoFond;
	private Image imgFond1;
	private Image imgFond2;
	private ImageIcon icoMario; 
	private Image imgMario; 
	private int xFond1;
	private int xFond2;
	private int xdx;
	public Scene(){
		super();
		this.xFond1 = -50;
		this.xFond2 = 750;
		this.xdx = 0;
		icoFond = new ImageIcon(getClass().getResource("/images/fondEcran.png"));
		this.imgFond1 = this.icoFond.getImage();
		this.imgFond2 = this.icoFond.getImage();
		icoMario = new ImageIcon(getClass().getResource("/images/marioMarcheDroite.png"));
		this.imgMario = this.icoMario.getImage();
		this.setFocusable(true);
		this.requestFocusInWindow();
		this.addKeyListener(new Clavier());
		Thread chronoEcran = new Thread(new Chrono());
		chronoEcran.start();
	                   }

	public int setXdx() {return xdx;}
	public void setXdx(int dx) {this.xdx = dx;}
	public void deplacementFond()

	

	{this.xFond1 = this.xFond1 - this.xdx;
	this.xFond2= this.xFond2 - this.xdx;

if (this.xFond1==-800)

{this.xFond1=800;}

else if (this.xFond2==-800)

{this.xFond2=800;}

else if (this.xFond1==800)

{this.xFond1=-800;}

else if (this.xFond2==800)

{this.xFond2=-800;}
	}
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		Graphics g2 = (Graphics2D)g;
		this.deplacementFond();
		g2.drawImage(this.imgFond1, this.xFond1, 0, null); // Dessin de l'image de fond 

		g2.drawImage(this.imgFond2, this.xFond2, 0, null); // Dessin de l'image de fond 
 		g2.drawImage(imgMario, 300, 245, null); //*** code provisoire

	}

}



***********************


***********************

تعليقات
ليست هناك تعليقات
إرسال تعليق

إرسال تعليق

الاسمبريد إلكترونيرسالة