Developing Games on the Raspberry Pi by Seth Kenlon

Developing Games on the Raspberry Pi by Seth Kenlon

Author:Seth Kenlon
Language: eng
Format: epub
ISBN: 9781484241707
Publisher: Apress


-- draw table background

ground = love.graphics.newQuad(0,0,WIDE,HIGH,150,150)

tile = love.graphics.newImage('img' .. d .. 'tile.jpg')

tile:setWrap('repeat','repeat')

end

The first card you generate is the “top” of the draw deck for the player. Since it’s the back of a card, it has no color or value, so you pass in the "c" and "v" dummy values, which the card library ignores once it sees that the card being generated is of the back type. The card’s X position is set at the left plus the value of pad, a variable set in main.lua to provide padding around the edges of the screen. The card’s Y position is calculated from the height of the screen.

The card generated is added to the back table. Then the same variable is used to generate a second card to represent the AI’s draw deck, using new X and Y values so that the card’s placement is in the top right (across the virtual table) instead of the bottom left. This second card is also added to the back table.

Finally, a proper tabletop is defined. Currently, the game mode only renders a flat color in the background, but Battlejack deserves something more exciting. Rendering an array based on a texture or pattern is pretty common for a game engine, and LÖVE provides the love.graphics.newQuad function to map tiles across a given space. Specifically, this code defines a quad of the width and height of the screen, with tiles sized 150×150 pixels (which happens to be the size of the tile pattern included with the source code of this book). The tile is defined using the d variable to ensure compatibility with whatever system the game is running on, and the tile mode is set to wrap seamlessly across all available space.

Currently, nothing calls the game.setup() function, so trigger it at the end of the game.new() function, since a user starting a new game certainly expects their game to be set up. game.setup()



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.