Paralax scrolling

BlitzMax Forums/BlitzMax Beginners Area/Paralax scrolling

Philip7(Posted 2008) [#1]
Hi, i'm new to gameprogramming so i have some trouble understanding what every is talking about with the discussion on tile-thingy's and such.

I changed some scrolling code to my needs and this works:

Global Schermbreedte: Int = 1024
Global Schermhoogte: Int = 768
Global Schermkleurdiepte: Int = 32

Graphics Schermbreedte, Schermhoogte, Schermkleurdiepte

Type TParalax                

	Field speed:Float		
	Field x:Float
	Field y:Int
	Field width:Int		
	Field cycle: Int
	Field img:TImage
	
	Function Create:TParalax(nx:Int, ny:Int, width:Int, speed:Float, ncycle: Int, imgFile:String)
		Local layer:TParalax = New TParalax
		layer.speed = speed
		layer.x = nx
		layer.y = ny
		layer.width = width
		layer.cycle = ncycle * width	
		layer.img = LoadImage(imgfile)
		ListAddLast ParalaxList, layer	
		Return layer
	End Function
	
	Method Update()			
		x = x - speed			
		If x < -width; x = 0	
		If cycle > 0; cycle:-1
		If cycle = 0; ListRemove(ParalaxList,Self)
		DrawImage(img, x, y)	
		If x < -(width - Schermbreedte); DrawImage(img, x+width, y)	
	End Method
			
End Type

Global ParalaxList:TList=CreateList()

Global Scroll0:TParalax = TParalax.Create(0, 0, 2048, .001, -1, "incbin::background-1a.png")
Global Scroll1:TParalax = TParalax.Create(0, Schermhoogte-280, 1200, .2, -1, "incbin::mountains.png")
Global Scroll2:TParalax = TParalax.Create(0, Schermhoogte-230, 2475, .4, 1, "incbin::buildings.png")
Global Scroll3:TParalax = TParalax.Create(0, Schermhoogte-256, 1024, .5, -1, "incbin::crackice.png")


(I do comment my code but it's in Dutch so i deleted it for the forum)

After reading a lot on the forum i found a lot of people talking about using tiles instead of my way because it's better smoother etc. Now that i want to make a level, have different pictures after eachother i'm getting the idea my code is going to become quite chaotic. So i'm looking for the 'right' to way to do this.

Can anyone explain to me what up with the tile stuff?
Everywhere i look i find lots of indepth technical stuff when i first want to understand the basics about it.

Does anyone know where to find a BlitzMax example on this?
After googling for hours and being sent from link to link i've become a little frustrated with it. Also, a lot of the info on the forum is years old and the links to sources dont work any more.

Trying to make a simple 2D sidescrolling shooter seemed like the perfect way to start learning BlitzMax....
After seeing Platypus i just have to try and make something like it, sure my graphics will totally suck and its not going to be so complex but i'm hoping its a nice start.


Grey Alien(Posted 2008) [#2]
It sounds great that you are trying to make a 2D sidescrolling shooter, but they are not that simple to program. You could try something simpler...Also googling for tilemaps may help. You can always type BlitzMax after your search term in google and it will search these forums better than the forum search facility.


MGE(Posted 2008) [#3]
What you're doing is ok for repeating backgrounds, but I would use smaller sizes. But for foreground objects and the map the sprite will interact with it's better to use smaller tiles.


Philip7(Posted 2008) [#4]
I may have over simplefied my skills. Im a 29 year old Business Intelligence consultant with a computer science degree. Years ago, before i was tempted by the dark side of IT (databases and datawarehouses), i actually learned to program in Assembler, Delphi, C++ and Java but that knowledge is very rusty at the moment. I even touched Java3D for a while but i felt dirty afterwards. Oh yeah, i starting programming text adventures on my Atari XL600 when i was 10.

A few months ago i needed to get some information out of an old mainframe with a hiearchical database for which i learned myself EasyTrieve (a Cobol variant) and rediscovered my passion for Basic.

I have always been more of database guy then a 3d game programmer but lately i found myself wanting to learn more about gameprogrammming in my spare time. I tried .Net gameprogramming, bought a few .Net books on it. After a few weeks i discovered that i want to be busy with making the actual game instead of spending hours on end just to get all components set up and running. I'm an instant-gratification kind of guy.

BlitzMax gives me this out-of-the-box functionality so i'm very happy with it. But, back in the nineties, when my classmates were thinking up 3D engines, i was building administrative applications. But now, BlitzMax gives me collision detection and spritefunctionality fairly easy so i only need to know some mechanics for a scrolling background and i'm set to go.

Yesterday i was tired after a long day of work and just couldn't find the resources no matter how much i googled. Today i found a good explanation on Tile maps and a nice code example here. So thanks for the feedback and yes, i will google first when i'm awake instead of asking here when i'm almost asleep :)

By the way, congratulation on your job in Canada Grey Alien. I hope the pay is good, some of my friends work for a company on Wii games and they make next to nothing unless the game sells really good. Seems to be a choice between earning the big bucks and working for passion.


Grey Alien(Posted 2008) [#5]
Well enjoy using the language it's great fun and it sounds like you'll be able to get a lot out of it with your skill set. Glad you found some examples.

So basically you use tiles to construct a huge game area, but clearly you don't draw all of it you just decide where your "viewport" (screen) is and draw only the visible tiles (including the ones half off the screen due to scrolling). If you want parallax, I assume that some of your tiles are transparent or won't be drawn at all. You simply make ANOTHER tilemap for them and move the viewport at a different speed from the main one when the player (ship) moves. Obviously you draw the slower moving tilesmaps first. You may even want a faster moving tilemap in FRONT of the main play area for overhanging stuff that the player goes behind.

Thanks for the congrats about my job. Yeah they are paying a good salary to make games + a bonus as an incentive to make them even better. To me I rather say I'd have BOTH big bucks and passion, instead of Either/Or ;-) This is a good life philosophy for many things, except for eating puddings if you want to remain slim.