Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / game

Paper Down Hill

4.75/5 (3 votes)
28 Jul 2013CPOL2 min read 8.5K  
A four-player soap-box time-trial game with a twist.

This article is an entry in our AppInnovation Contest. Articles in this sub-section are not required to be full articles so care should be taken when voting.

Image 1

Introduction

"Paper Down Hill" is a 2D soap-box time-trial game where up to four players can take part either as a cooperative team, or working against each other. 

The game is aimed at the "All-In-One" platform and the corresponding  "Games"category.   

Overview 

The game starts by taking 3 pictures of the players (up to four) using the built-in web-cam.  These images are later used for the cart-driver's head in the game as shown below.

Image 2 

The main game then consists of a number of trials selected by the group.

Each trial consists of 2 phases, a 5 second setup phase where everyone gets to adjust the shape of the cart (the size of the wheels, the position of the seat, how fat the driver is).

Then the driver is picked at random and they have to try and make it down the hill as fast as possible without falling out of the cart.

Image 3 

The other, non-driving players help or hinder the driver by throwing objects at them.

A link to a video showing some of the 2D physics in action can be found here

Development 

The game is being developed using App Game Kit (AGK) v108, utilising the Tier 1 command set.   AGK's basic Tier1 language enable rapid development for a single develop like me, but also enables easy access to the deeper features within the hardware, such as multi-touch points, the accelerometers, gyros, etc.

For example; the following few lines, cover the image capture and processing: 

//take player photos
dim NewHeadImg[2] as integer
dim ModHeadImg[4,2] as integer 
ImagesTaken = 0
if GetCameraExists()=1
	for p=1 to totalplayers
		//use camera
		repeat
			repeat
				ShowImageCaptureScreen()
				repeat
					sync()
				until ISCAPTURINGIMAGE() =0
				NewHeadImg[ImagesTaken]=GETCAPTUREDIMAGE()
			until NewHeadImg[ImagesTaken]>0
			ImagesTaken = ImagesTaken+1
       	 	until ImagesTaken>2
		//mod images
		ImagesTaken=0
		repeat
			HeadMemBlk = CreateMemblockFromImage(NewHeadImg[ImagesTaken])
			imgW = GetMemblockInt(HeadMemBlk,0)
			imgH = GetMemblockInt(HeadMemBlk,4)
			//ellipse values
			a# = 120.0
			b# = 200.0
			for row = 0 to imgH-1
				for col = 0 to imgW-1
					r# = abs(row-(imgH/2.0))
					if (1.0-((r#/b#)^2))>0.0
						clim = trunc(sqrt((1.0-((r#/b#)^2))*(a#^2)))
						climlo = (imgw/2)-clim
						climhi = (imgw/2)+clim
						if (row<(0.125*imgH) or row>(0.875*imgH) or col<(climlo) or col>(climhi))
							rem *** Calculate offset to alpha value ***
							offset = row*imgW*4+col*4+15
							SetMemblockByte(HeadMemBlk,offset,0)
						endif
					else
						offset = row*imgW*4+col*4+15
						SetMemblockByte(HeadMemBlk,offset,0)
					endif
				next col
			next row
			ModHeadImg[p,ImagesTaken] = CreateImageFromMemblock(HeadMemBlk)
			ImagesTaken = ImagesTaken+1
		until ImagesTaken>2
	next p
endif 

The initial points of the game are already constructed although there are still large parts to work one such as the majority of the artwork, multi-player and multi-touch implementation.  The idea is relatively simple with a lot of scope to expand on, such as drawing your own hills, or cart components. 

Points of Interest

The game will utilise the multi-touch functionality of the AIO, allowing players to directly drag and through their own sprites around the screen.  

The game also utilises the built-in web game to place the players inside the game . 

History

[2013.07.27] - Initial draft.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)