Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MoteurDeJeu
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Villard PierreFrederic
MoteurDeJeu
Commits
ae503abb
Commit
ae503abb
authored
3 years ago
by
Villard PierreFrederic
Browse files
Options
Downloads
Patches
Plain Diff
Add background scrolling
parent
ebb4f677
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/afficheur/Afficheur.java
+5
-2
5 additions, 2 deletions
src/afficheur/Afficheur.java
src/afficheur/DecorVariable.java
+64
-0
64 additions, 0 deletions
src/afficheur/DecorVariable.java
with
69 additions
and
2 deletions
src/afficheur/Afficheur.java
+
5
−
2
View file @
ae503abb
...
@@ -29,7 +29,9 @@ public class Afficheur extends JPanel {
...
@@ -29,7 +29,9 @@ public class Afficheur extends JPanel {
Monde
m
;
Monde
m
;
//l'afficheur de Decor
//l'afficheur de Decor
public
DecorFixe
decor
=
new
DecorFixe
();
//public DecorFixe decor=new DecorFixe();
public
DecorVariable
decor
=
new
DecorVariable
();
//double buffering
//double buffering
BufferStrategy
bs
;
BufferStrategy
bs
;
...
@@ -75,7 +77,8 @@ public class Afficheur extends JPanel {
...
@@ -75,7 +77,8 @@ public class Afficheur extends JPanel {
g
.
setColor
(
Color
.
black
);
g
.
setColor
(
Color
.
black
);
//affiche le décor
//affiche le décor
decor
.
affiche
(
g
);
//decor.affiche( g);
decor
.
affiche
((
int
)
m
.
balle
.
px
,
g
);
// affiche les objets
// affiche les objets
for
(
Objet
obj
:
m
.
objets
)
{
for
(
Objet
obj
:
m
.
objets
)
{
...
...
This diff is collapsed.
Click to expand it.
src/afficheur/DecorVariable.java
0 → 100644
+
64
−
0
View file @
ae503abb
package
afficheur
;
import
java.awt.Graphics
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
javax.imageio.ImageIO
;
//distributeur de sprites
public
class
DecorVariable
{
//IMage
BufferedImage
im
;
//taille
int
wx
,
wy
;
//construit le sprite
public
DecorVariable
()
{
try
{
im
=
ImageIO
.
read
(
new
File
(
"background.jpg"
));
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
System
.
out
.
println
(
"erreur lecture background"
);
}
wx
=
im
.
getWidth
();
wy
=
im
.
getHeight
();
}
public
void
changeImage
(
String
image
)
{
try
{
im
=
ImageIO
.
read
(
new
File
(
image
));
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
System
.
out
.
println
(
"erreur lecture background"
);
}
wx
=
im
.
getWidth
();
wy
=
im
.
getHeight
();
}
//afficheur de decor
//declae en x seulement
public
void
affiche
(
int
x
,
Graphics
g
)
{
//on se ramene au repere du plan
x
=(
x
%
wx
);
//on affiche sur l'ecran 0 ==> wx-x image source de x � wx
g
.
drawImage
(
im
,
0
,
0
,
wx
-
x
,
wy
,
x
,
0
,
wx
,
wy
,
null
);
//on affiche sur l'ecran wx-x ==> wx image source de 0 � x
g
.
drawImage
(
im
,
wx
-
x
,
0
,
wx
,
wy
,
0
,
0
,
x
,
wy
,
null
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment