Home » Extra libraries, Code snippets, applications etc. » Applications created with U++ » CastleBuilder - simply 2D platform game with editor 
	
		
		
			| CastleBuilder - simply 2D platform game with editor [message #44363] | 
			Sun, 01 March 2015 14:48   | 
		 
		
			
				
				
				  | 
					
						  
						Klugier
						 Messages: 1106 Registered: September 2012  Location: Poland, Kraków 
						
					 | 
					Senior Contributor  | 
					 | 
		 
		 
	 | 
 
	
		Hello, 
 
I would like to show my last year project for my studies. It was implemented on "Programing games in C++" course (2013/2014 - summer). This is simply 2D platform game with level editor. 
 
Features: 
- level is represented by special xml file (save/load feature is implemented). 
- level debugging feature. 
- whole written in Upp. 
- game is rendering using "Painter". 
- game scrolling. (Level can be bigger than screen resolution) 
- layers support. 
- around 2,5K lines of code. 
 
  
 
Sincerely, 
Klugier 
		
		
  U++ - one framework to rule them all.
		[Updated on: Sun, 01 March 2015 16:01] Report message to a moderator  
 |  
	| 
		
	 | 
 
 
 |  
	| 
		
 |  
	| 
		
 |  
	| 
		
 |  
	| 
		
 |  
	
		
		
			| Re: CastleBuilder - simply 2D platform game with editor [message #44554 is a reply to message #44408] | 
			Fri, 27 March 2015 21:26    | 
		 
		
			
				
				
				  | 
					
						  
						Klugier
						 Messages: 1106 Registered: September 2012  Location: Poland, Kraków 
						
					 | 
					Senior Contributor  | 
					 | 
		 
		 
	 | 
 
	
		Hello Deep, 
 
In layer code there is really no magic. Unless you want to play with transparency (My simply engine doesn't allow that). 
 
Here is part of draw level method: 
	for (int layer = level.getLayers() - 1; layer >= 0; layer--) {
		for (int row = 0; row < level.getRows(); row++) {
			for (int col = 0;  col < level.getCols(); col++) {
				int x0 = col * c - view.x;
				int y0 = row * c - view.y;
				
				// Don't paint invisible ellements
				if (x0 + c > 0 && y0 + c > 0 && x0 - c < sz.cx && y0 - c < sz.cy) {
					drawElement(bp, layer, row, col, x0, y0, c, complete || gameOver);
				}
			}
		}
                // ... draw player, draw enemies etc. ...
	}
 
 
P.S. 
I will consider making this code open source. But, firstly I will need to do some code cleaning's... 
 
Sincerely, 
Klugier 
		
		
  U++ - one framework to rule them all.
		[Updated on: Fri, 27 March 2015 21:26] Report message to a moderator  
 |  
	| 
		
	 | 
 
 
 |  
	| 
		
 |   
Goto Forum:
 
 Current Time: Tue Nov 04 13:23:57 CET 2025 
 Total time taken to generate the page: 0.05623 seconds 
 |