Great tutorial, but how would you make it to where the background scrolls automatically over time rather than linking it to movement? Much like it does in side scrolling space shooters, for example.
@schwartz0420 In the move() method, make the x-value increase steadily, like nx2 = nx2 + 2
Then you make your dude fixed by removing his x-movement and you have a fixed dude moving on his own to the right (seemingly, it's actually the background that moves to the left).
I'm doing that, but for some reason, every time the background loops two times, it stops looping once (tried adding a third, but then it stopped looping every third panel).
I guess one thing that made me overcomplicate things was my stubborn-ness to use a system similar to SNES, SEGA Genesis, Game Boy, NES, etc using a system of tiles - no winder my brain aches, this is much simpler.
Dear 2 - Java 2D side scrolling Game Tutorial (part 1) - Scrolling background Bones-underground is a 2d mmorpg. It is absolutely free to play indefinately. We offer a great community, a place where you can become rich and famous, or just hang out with a few friends. We have hundreds of weapons and armors to choose from. You may want to get a pet, or maybe do a little fishing and heaps more game play on my profile and link!!
@Mattedatten the 2400 is twice the width of the background image, i didn't completely understand this, but i think it allows the image to be created twice so that you have an image generating that you're about to walk on, while also having the image you're walking on currently
@Mattedatten You have the locations of two backgrounds being controlled (one by variable nx, one by nx2). The goal is to reset the value of nx and nx2 at a point to 0 (start of frame) and continue to increase their values, to simulate moving right.
As you can see, when x is 590 the first bg resets, at 1790, 2nd bg resets, at 2990 1st bg resets then at 4190 2nd bg resets. Each are 1200 apart (size of frame) and each bg reset is 2400 apart (590,2990, etc). This is where the mod 2400 comes from.
@MissCNSingh look at the previous in the series, where he codes the basic game, but if you want here it is anyway: public Board() { p = new Player(); addKeyListener(new AL()); setFocusable(true); ImageIcon i = new ImageIcon("FILE LOCATION"); img = i.getImage(); time = new Timer(5, this); time.start(); }
You should have most of the code in the JFrame though.....That way it is using objects and modifying them in the main class instead of using the Jframe just as a display. This also makes it very hard to double Buffer. My question is if you are using a Jframe then why are you not using a Buffer??? You are still using repaint() which inherently lags and you didn't even change the update() to double buffer. Which means you fail as a Java programmer :)
Hey nice video you have posted. I am also working on a sidescroller, but using C/C++ instead!
Now, I have an offtopic question, what program are you using to record your screen? I've tried a couple of them out there, but none of them is really fulfilling my needs!
@TheTIprogrammer That's a shorter version which is neat I like using it too, but since this is a tutorial I think writing it the long way would make more sense to those programmers who don't know that shorter version.
im getting a error: Description Resource Path Location Type
The method getY() is undefined for the type Dude Board.java /Terrarium/src/TerrariumPackage line 32 Java Problem help plz? :)
MattiasRosendahl 1 week ago
heyy i was kinda wondering im going to make a game like terraria what engine should i use?
leyniapi 1 week ago
ok so i fixed my errors from the last vid but now the back ground is not showing up can you help me asap pls
PXP217 3 weeks ago in playlist More videos from MrJavaHelp
Great tutorial, but how would you make it to where the background scrolls automatically over time rather than linking it to movement? Much like it does in side scrolling space shooters, for example.
schwartz0420 1 month ago
@schwartz0420 In the move() method, make the x-value increase steadily, like nx2 = nx2 + 2
Then you make your dude fixed by removing his x-movement and you have a fixed dude moving on his own to the right (seemingly, it's actually the background that moves to the left).
I'm doing that, but for some reason, every time the background loops two times, it stops looping once (tried adding a third, but then it stopped looping every third panel).
Math + Saturday != working >.<
morphman86 1 month ago
I guess one thing that made me overcomplicate things was my stubborn-ness to use a system similar to SNES, SEGA Genesis, Game Boy, NES, etc using a system of tiles - no winder my brain aches, this is much simpler.
travelsonic 1 month ago
Move the mic away a little bit from your face.
dennan98 2 months ago in playlist Fler videoklipp från MrJavaHelp
Its not working. Its only running the JFrame class. Please, please, please help!
Jdesai840 2 months ago
oh, didn't add the code, /E08h3wQ0
999FRIZFRAZ999 2 months ago in playlist Java Game Programming: 2D Side Scroller
Comment removed
999FRIZFRAZ999 2 months ago in playlist Java Game Programming: 2D Side Scroller
on my one, it scrolls as it is supposed to but it stops repeating after a bit, here's the code:
999FRIZFRAZ999 2 months ago in playlist Java Game Programming: 2D Side Scroller
My character moves faster than the background moves. Why is this?
FloormanUK 2 months ago
Comment removed
portalrulez 2 months ago
@FloormanUK Somethings not synced
jrinkthedew 2 months ago
Bad audio AGAIN! This time worse than the last. Back off the mic by 3 inches.
johnnycarson67 4 months ago 4
HI where is the left character picture to download?
DARKOOMER 4 months ago
@DARKOOMER he didn't give it cuz u can just flip the image on the editor
bergersportboy2q 2 months ago in playlist Java Game Programming: 2D Side Scroller
why is the mic so close 2 your mouth!
LifeGivesUsHope 5 months ago 2
Eclipse FTW!
TheRandomInternetGuy 5 months ago
Comment removed
TheAngel2ome 6 months ago
Great job!!
lamarts100 7 months ago
This has been flagged as spam show
Dear 2 - Java 2D side scrolling Game Tutorial (part 1) - Scrolling background Bones-underground is a 2d mmorpg. It is absolutely free to play indefinately. We offer a great community, a place where you can become rich and famous, or just hang out with a few friends. We have hundreds of weapons and armors to choose from. You may want to get a pet, or maybe do a little fishing and heaps more game play on my profile and link!!
boneug 8 months ago
This has been flagged as spam show
how do i shit?
wedo4567 8 months ago
dude back up from the mic
TVisOutrageous 9 months ago 2
check out my java game Defend the Portal..source code at link in description
youtube /watch?v=-3I_hUg06Dg
kylecowan990 10 months ago
thanks for ur tutorial, but ehh
you should buy a better micro or work or your voice:P
sometimes it hard to listen to your voice
rickvangils100 10 months ago
u sound like those army guys in half life 1
plutgamer 11 months ago
Thanks for the videos!!
JaguerRhye 11 months ago
were
200Godzilla 11 months ago
@200Godzilla
1) download the JDK (Java Development Kit)
2) Download JRE (Java Runtime Environment) You might have this already updated but just download it
2) Download Eclipse IDE for Java
kidMallok 11 months ago
were can i download java 2?
200Godzilla 11 months ago
Interesting
torocity 1 year ago
if( (p.getX() - 1790) % 2400)
I do understands what it does, but where does the value "2400" come from?
Thanks for great tutorials btw :)
Mattedatten 1 year ago 9
@Mattedatten
I think 2400 stands for the width (in pixels) of the background picture
UntouchableX7 11 months ago
@Mattedatten the 2400 is twice the width of the background image, i didn't completely understand this, but i think it allows the image to be created twice so that you have an image generating that you're about to walk on, while also having the image you're walking on currently
dirnol 11 months ago
@Mattedatten You have the locations of two backgrounds being controlled (one by variable nx, one by nx2). The goal is to reset the value of nx and nx2 at a point to 0 (start of frame) and continue to increase their values, to simulate moving right.
As you can see, when x is 590 the first bg resets, at 1790, 2nd bg resets, at 2990 1st bg resets then at 4190 2nd bg resets. Each are 1200 apart (size of frame) and each bg reset is 2400 apart (590,2990, etc). This is where the mod 2400 comes from.
MrJavaHelp 9 months ago 2
"javarpg#co#nr" , for some great java rpg tutorial => replace "#" by "."
eatMeification 1 year ago
Comment removed
biggerthanblue 1 year ago
hiya do you have a vid on how to place the background image on the game
MissCNSingh 1 year ago
@MissCNSingh look at the previous in the series, where he codes the basic game, but if you want here it is anyway: public Board() { p = new Player(); addKeyListener(new AL()); setFocusable(true); ImageIcon i = new ImageIcon("FILE LOCATION"); img = i.getImage(); time = new Timer(5, this); time.start(); }
matthewj234 1 year ago
You should have most of the code in the JFrame though.....That way it is using objects and modifying them in the main class instead of using the Jframe just as a display. This also makes it very hard to double Buffer. My question is if you are using a Jframe then why are you not using a Buffer??? You are still using repaint() which inherently lags and you didn't even change the update() to double buffer. Which means you fail as a Java programmer :)
JetFusion99 1 year ago
@JetFusion99 you're an asshole.
driojas 1 year ago
@driojas Lol! That made me laugh.
ekojk1242 11 months ago
This has been flagged as spam show
Do something about your mic
violetcitron 1 year ago
Awesome guide :)
Wallelo 1 year ago
Hi!
I do not understand why why have to make the test:
if(p.getX() == 1790) p.nx2 = 0;
in the Board class.
Could someone explain me it?
macogala 1 year ago
Hey nice video you have posted. I am also working on a sidescroller, but using C/C++ instead!
Now, I have an offtopic question, what program are you using to record your screen? I've tried a couple of them out there, but none of them is really fulfilling my needs!
Thanks and keep up with the good work!
KuramaYoko10 1 year ago 8
@KuramaYoko10 camtasia studio
matthewj234 1 year ago
@KuramaYoko10 Hypercam2 is the best one
taumich97 6 months ago
@KuramaYoko10 he's using Camtasia Studio... best Recorder and Editor all in one...
mrdrinuman 4 months ago
what program is u using ?????
oll187 1 year ago
@oll187 It's Eclipse
macogala 1 year ago
instead of: nx2 = nx2+dx; use nx2+=dx;
TheTIprogrammer 1 year ago
@TheTIprogrammer That's a shorter version which is neat I like using it too, but since this is a tutorial I think writing it the long way would make more sense to those programmers who don't know that shorter version.
SteveSpieldberg360 1 year ago
@SteveSpieldberg360 Not being rude, but if they were wanting to make a game; the should know basic Java. =)
TheTIprogrammer 1 year ago
@TheTIprogrammer lol good point
SteveSpieldberg360 1 year ago
THANKS
MrKryddarn 1 year ago
Thx for your videos
keccolinUni 1 year ago