Knights!

Miscellaneous Forums/Blitz Showcase/Knights!

In an effort to get myself back into game making I decided to enter a little forum competition to make NES-like games (i.e. 3 colours per sprite and so on). I ended up drawing a load of castle-ish backgrounds and a little knight, so decided on a sort of Bubble Bobble game where you beat up little goblins who are stealing your gold and stuff. I've not started on the code yet because I haven't coded a platformer yet and I trying to get as much planning done as possible before getting a line of code down. Anyway, here's a little mock screen!



Does anyone have any tips for coding platformers?



I love NES style games, yours is looking cool. I wish you the best of luck with it. Please post when it`s done, btw is there a closing date to this comp as I cannot seem to find one. Are you using MS Paint for the graphics just out of interest?

Jason.

Looks cool. Reminds me of an old 8-bit game with the knight and everything - the name of which escapes me.

[edit] Ah, Spellbound!



You just need to give each room a wacky name. :)

My only Platformer Request is that it's abundantly clear which areas you can jump on (ie platforms), and which areas are just for decoration.

Nigh-on self-evident why that's handy, methinks. :o)

@GfK: I think there was another Speccy game called KnightTyme which has kinda part-influenced the little character along with the black knight dude that appears sometimes in the Bomberman games.

@QuickSilva: I'm using GraphicsGale for the sprites and backgrounds, a kinda souped up version of MSPaint, made with game creation in mind.

@LineOf7s: Hopefully it'll be more obvious, I'll see when I get it in motion.. :P

Heh, kind of cutsie-looking - looking good

Looking good!

gfk - hmmm..that game looks like "finders keepers"..you
controlled a little knight + had to collect stuff...er..yeh, thats
about all i remember ;)

Looks very crisp and clean. Some folks would have blurred the hell out of the graphics by now. I prefer clean images, very well done. Your tecnique is spot on. Do yoy plan to work with all the limits of the nes or just three colors per sprite.

> Does anyone have any tips for coding platformers?

you could try looking at Wolron's Pitfall II source for tips.
http://www.blitzbasic.com/codearcs/codearcs.php?code=1224

@Defoc8: Finders Keepers! I remember that one! It was basically a maze game with moving enemies and Dizzy-esque proportions of collecting/trading items. Yeh, I think that's another one subliminally embedded in my unconscious.

@Ryan: I don't think I could handle with 'all' the limitations. The three colours per sprite thing is a good exercise though because it makes you appreciate how hard it is make a simple sprite look good. I'm trying to keep within the traditional NES palette as well so there may be some tweaking at a later date.

@muk: Cheers, I'm checking it out now.

love the graphics, I always wondered what GraphicsGale was like, been meaning to try it out...

Where is this forum competition at? I wouldnt mind jumping in for go...

Does anyone have any tips for coding platformers?



Graphics 800,600

Global dude = CreateImage(20,20)
SetBuffer ImageBuffer(dude)
Color 255,0,0
Oval 0,0,20,20,1

Global dline = CreateImage(20,3)
SetBuffer ImageBuffer(dline)
Color 155,50,0
Rect 0,0,100,3,1

Global pltf = CreateImage(200,30)

SetBuffer ImageBuffer(pltf)
Color 155,250,0
Rect 0,0,200,30,1

Global pltfl = CreateImage(200,3)

SetBuffer ImageBuffer(pltfl)
Color 255,255,255
Rect 0,0,200,3,1


SetBuffer BackBuffer()
Global jumpheight# = 10

Global canjump = 0

Global jump = 0



Const gravity# = 0.4



	Type player



		Field x#

		Field y#

		Field h#

	
	End Type

	
	
	Type platform

	
		Field x

		Field y

		Field g

		
	End Type

	
	
createplatform()

	
createplayer()





While Not KeyHit ( 1 )



	Cls

		
			Text 50,50,"Jumpheight = " +Int(jumpheight)

			
			drawlines()		

			renderplatform()

			renderplayer()

			moveplayer()

			playerjump()

			collisionchecks()

	
	Flip

	
	
Wend





End



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;									   ;

;	Function : Draw Lines			   ;

;									   ;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



Function drawlines()



	For p.player = Each player

	
		DrawImage dline,p\x + 3,p\y + 50

		
	Next

	
	For plat.platform = Each platform

	
		DrawImage pltfl,plat\x,plat\y - 1

	
	Next

	
	
End Function





;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;									   ;

;	Function : Create Platform		   ;

;									   ;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



Function createplatform()



	plat.platform = New platform

	
		plat\x = 400

		plat\y = 535

		
End Function





;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;									   ;

;	Function : Create Player		   ;

;									   ;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



Function createplayer()



	p.player = New player

	
	p\x = 300

	p\y = 540

	p\h = 10

	
End Function



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;									   ;

;	Function : Render Player		   ;

;									   ;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



Function renderplayer()



	For p.player = Each player

	
		DrawImage dude,p\x,p\y,0

		
	Next

	
End Function



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;									   ;

;	Function :Render Platform		   ;

;									   ;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



Function renderplatform()



	For plat.platform = Each platform

	
		DrawImage pltf,plat\x,plat\y

		
	Next

	
End Function





;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;									   ;

;	Function : Move  Player 		   ;

;									   ;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



Function moveplayer()



	If KeyDown ( 203 )

	
		For p.player = Each player

		
			p\x = p\x - 3

			
		Next

		
	ElseIf KeyDown  ( 205 )

	
		For p.player = Each player

		
			p\x = p\x + 3

			
		Next

		
	EndIf

	
	For p.player = Each player

	
		If p\y > 540 Then

		
			p\y = 540

			canjump = 0

			jump = 0

			jumpheight = 10

			
			
		EndIf

		
	Next

		
	
End Function



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;									   ;

;	Function : Player Jump 			   ;

;									   ;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



Function playerjump()



	If KeyHit ( 57 ) And (jumpheight = 10 Or Int(jumpheight) = -1);(Int(jumpheight = -1)))

		
		canjump = 1

		jump = 1

		jumpheight = 10

				
	EndIf

	
	If  canjump = 1 And jump = 1 Then 

			
			If jumpheight <=0 Then

			
				For p.player = Each player

				
					For i = 0 To 1 + Abs(jumpheight)

						
						If collisionchecks() = True Then Exit

						
						p\y = p\y + 1

						
					Next

					
				Next

			
			Else

												
				For p.player = Each player

		
					For i = 0 To jumpheight

					
						If collisionchecks = True Then Exit

				
						p\y = p\y - 1

												
					Next

														
				Next

			
			EndIf

		
		
			
		jumpheight = jumpheight - gravity

		
		
			 
	Else

		
		jump = 0

		canjump = 0

		jumpheight = 10

		
	EndIf

		
		
End Function 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;									   ;

;	Function : Collision checks		   ;

;									   ;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



Function collisionchecks()



	For p.player = Each player

		
		For plat.platform = Each platform	

		
			If ImagesCollide(dline,p\x + 3,p\y + 50,0,pltfl,plat\x,plat\y - 1,0) And jumpheight <0 Then

			
				canjump = 1

				jump = 0

				
				Return True

				
			ElseIf  p\y <540 And jumpheight = 10 Then

			
				canjump = 1

				jump = 1

				jumpheight = -1

				
				Return True

				
			EndIf

			
		Next

		
	Next

	
	
	
Return False



End Function






CREDIT to ORIGINAL POSTER
dunno who they were, but this snippet was posted in these forums a while back...

hope it helps...

Hehe, I only wish that I would've been that phenomenal.

I thought this was gonna be the amiga PD games Knights

nice example, keyboard. i think Amon is the original poster.
http://www.blitzbasic.com/Community/posts.php?topic=26266

i tidied it up a bit. it now works in different resolutions.
;2d Platform code, by Amon

width=640 : height=480 : window=2
;width=800 : height=600 : window=0
Graphics width,height,0,window

Global dude = CreateImage(20,20)
SetBuffer ImageBuffer(dude)
Color 255,0,0 : Oval 0,0,20,20,1

Global dline = CreateImage(20,3)
SetBuffer ImageBuffer(dline)
Color 155,50,0 : Rect 0,0,100,3,1

Global pltf = CreateImage(200,30)
SetBuffer ImageBuffer(pltf)
Color 155,250,0 : Rect 0,0,200,30,1

Global pltfl = CreateImage(200,3)
SetBuffer ImageBuffer(pltfl)
Color 255,255,255 : Rect 0,0,200,3,1

SetBuffer BackBuffer()

Global jumpheight# = 10
Global canjump = 0
Global jump = 0

Const gravity# = 0.4

Type platform
 Field x,y,g
End Type

Type player
 Field x#,y#,h#
End Type

createplatform()
createplayer()

;Main loop
While Not KeyHit(1)
 Cls

 Text 12,12,"Jumpheight = "+Int(jumpheight)

 drawlines()  
 renderplatform()
 renderplayer()
 moveplayer()
 playerjump()
 collisionchecks()

 Flip
Wend
End

;Function : Create Platform
Function createplatform()

 plat.platform = New platform
 plat\x = GraphicsWidth()/2 ;400
 plat\y = GraphicsHeight()-65 ;535

End Function

;Function : Create Player
Function createplayer()

 p.player = New player
 p\x = (GraphicsWidth()*100)/266 ;300
 p\y = GraphicsHeight()-60 ;540
 p\h = 10

End Function

;Function : Draw Lines
Function drawlines()

 For p.player = Each player
  DrawImage dline,p\x + 3,p\y + 50
 Next

 For plat.platform = Each platform
  DrawImage pltfl,plat\x,plat\y - 1
 Next

End Function

;Function : Render Platform
Function renderplatform()

 For plat.platform = Each platform
  DrawImage pltf,plat\x,plat\y
 Next

End Function

;Function : Render Player
Function renderplayer()

 For p.player = Each player
  DrawImage dude,p\x,p\y,0
 Next

End Function

;Function : Move Player
Function moveplayer()

 If KeyDown(203) ;left

  For p.player = Each player
   p\x = p\x - 3
  Next

 ElseIf KeyDown(205) ;right

  For p.player = Each player
   p\x = p\x + 3
  Next

 EndIf

 For p.player = Each player

  If p\y > GraphicsHeight()-60 ;540
   p\y = GraphicsHeight()-60 ;540
   canjump = 0
   jump = 0
   jumpheight = 10
  EndIf

 Next

End Function

;Function : Player Jump
Function playerjump()

 If KeyHit(57) And (jumpheight = 10 Or Int(jumpheight) = -1)
  canjump = 1
  jump = 1
  jumpheight = 10
 EndIf

 If canjump = 1 And jump = 1 

   If jumpheight <= 0

    For p.player = Each player
     For i = 0 To 1 + Abs(jumpheight)
      If collisionchecks() = True Then Exit
      p\y = p\y + 1
     Next
    Next

   Else

    For p.player = Each player
     For i = 0 To jumpheight
      If collisionchecks = True Then Exit
      p\y = p\y - 1
     Next
    Next

   EndIf

  jumpheight = jumpheight - gravity

 Else

  jump = 0
  canjump = 0
  jumpheight = 10

 EndIf

End Function 

;Function : Collision checks
Function collisionchecks()

 For p.player = Each player
  For plat.platform = Each platform 

   If ImagesCollide(dline,p\x + 3,p\y + 50,0,pltfl,plat\x,plat\y - 1,0) And jumpheight < 0
    canjump = 1
    jump = 0
    Return True
   ElseIf jumpheight = 10 And p\y < GraphicsHeight()-60 ;540
    canjump = 1
    jump = 1
    jumpheight = -1
    Return True
   EndIf

  Next
 Next

 Return False

End Function


Hehe, I only wish that I would've been that phenomenal.


hmmm ;)

I'm trying to keep within the traditional NES palette as well so there may be some tweaking at a later date.

Makes you kinda wish Blitz had a working 256-palette mode so you could do those little cool color-cycle effects they had back then running at full speed...

keyboard (Posted 14 hours ago)

Hehe, I only wish that I would've been that phenomenal.


hmmm ;)


Uhh, what? :gulp:

Ooh, I havn't played a platformer in a while! Sounds interesting, and good graphics!

good luck JimBob. I too played Spellbound (and another one) on the Spec/C64. There was a thread in General Discussion a while ago all about what elements would make a cool platform game, it may prove useful to you. Planning is good too, I made Iron Fist (incomplete kung fu platformer) as I went along, but luckily I'd made a lot of (incomplete) platformers in the past on BBC/spectrum/C64/Amiga/DOS. For modern platformers I was trying to get away from tile-based maps and have object-based levels instead so that everything didn't have that regular 32x32 look. Plus then you can move any objects you want and do other interesting stuff.

This project is a kinda launchpad for a platformer I've been planning for years now (I've refrained from starting it as I've too many projects running already). For that reason, I'm keeping it simple so that I can get the basics right. It's a factor where I find many freeware platformers fail, the controls don't feel intuitive, and spend most of development trying to fit in features that bloat the gameplay and actually make it less fun. I've always had it mind to make a game like Bubble Bobble, but never had the idea that could carry the gameplay. I'll see if this works out, but I think I have the gameplay bases covered.

It's not a case of having multiple moves or moving platforms sometimes, it's about the fun you get from bashing a little goblin across the room into your friend just as he's about to collect some gold....

I'll try and find that thread though...

try my platformer Iron Fist here: http://www.greyaliengames.com/games.php if you get a chance :-) it was done in BPlus in 2005.

i couldn't resist searching for that thread. :)
http://www.blitzbasic.com/Community/posts.php?topic=60961

cool, cos I forgot...

I've drawn a title screen in the absence of any real work on this project :P



The backgrounds a bit naff at the moment, but it's open to revision.

Haha, a lot like the old SNES games that I've used to play, this is gonna be great!