Jump to content
  • Advertisement

jeansberg

Member
  • Content Count

    7
  • Joined

  • Last visited

Community Reputation

4 Neutral

About jeansberg

  • Rank
    Newbie

Personal Information

Social

  • Twitter
    jeansblergh
  • Github
    jeansberg
  • Steam
    jeansberg

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Whoa, blast from the past. :) I did have a hard time exporting good GIFs for some reason. If it doesn't meet the quality standards, no hard feelings.
  2. Computer gaming has been my main hobby ever since I got a used Odyssey 2 when I was six, and even though I'm now a programmer by trade, I've yet to finish a game project of my own. I've definitely done game programming - I've followed Unity tutorials, started a couple of roguelike prototypes and messed around a bit with a shooter using Google Cardboard at a company hackathon. I even joined an on location game jam, but I encountered some technical problems with my idea and quickly realized 48 hours wouldn't be enough. I had also decided to sign up as a one man team, which meant I had no one else to motivate me to keep going. I have been thinking about applying for some game programming jobs at some point in the future, which has me motivated to work on my skills again. A friend recommended getting into Lua and Love2D, so I decided to try them out. You can get started with Love2D and have something on your screen very quickly, which made it attractive to me after having worked on a C++ project for the last few months. Since Lua is often used as a scripting language for other game engines, it seemed like a good road for me to go down. I started developing a simple shooting game with Love2D as I was learning the language and the framework. This turned into a series of blog posts that I plan to post on this site as well. While writing my tutorial series, I had also registered on itch.io and noticed their massive game jam calendar. I decided to join a jam called My First Game Jam: Summer 2017. I logged onto their Discord server and found a very active community discussing ideas and assembling teams. I talked to a few people and ended up agreeing to work on a project with another person. They would design and write and actually already had a pretty fleshed out idea. I would do the programming. We talked some more about the idea, and we both started getting excited. We decided this would be our first game under the name Micro Brood Games (we are both craft beer enthusiasts). The basic idea of Walk and Talk is that the player is walking with a friend while carrying on a conversation at the same time. If you pick too many incorrect answers, you lose. If you bump into too many obstacles or walk out into the street, you lose. The walking part of the game is controlled with the WASD keys and the answers to questions are picked with the arrow keys, forcing you to keep track of two parts of the screen at once. Since I was still on the Lua/Love2D kick, that's what I decided to use for development. The features I managed to implement before the deadline are: Movement and collisions between you and your friend / environment Randomly generated sequence of screens that scroll vertically Reasonably realistic movement for the friend AI Fail conditions for touching the top of the screen, answering questions incorrectly or not at all and for not using the sidewalk when crossing the street Win condition for reaching the end of the last screen Meters for friend annoyance level and time left for the current question The features I plan to implement before announcing the "Release" version of the game: Moving pedestrians to collide with Obstacles on the ground to avoid More variety in environments Gamepad support Configurable controls Splash screen and menus Better sprites and UI I will be writing a few more posts about Walk and Talk as I develop these features. After we are satisfied with this game, we will move on to the design phase for the next one! Here are some screens of the game jam version, which you can download here.
  3. Hello! This will be the first in a series of posts on developing a simple shoot 'em up game using the Lua programming language and the Love2D framework. I decided to make this game as a bit of a break from another game project that I've been working on for a while. I chose Lua and Love2D due to their focus on simplicity and efficiency. I will be writing these posts as I learn. Getting started In order to run the game we are making, you need to install the Love2D framework from https://love2d.org. You might also want to use an IDE or a plugin for your favorite text editor to get things such as autocomplete and syntax checking. Here is a list of such [tools](http://www.gamefromscratch.com/post/2016/01/25/Editors-and-IDEs-for-Lua-and-Love-Development.aspx). Personally I went with the Atom Editor plugin, since Atom is currently my favorite text editor. Let's write some code! After we have our tools set up, the first thing we'll do is simply create a folder containing a file named main.lua. This is where the Love2D executable will look for the game code's entry point. This is where we will put all our code for now. We will start by writing three very important functions: love.load() love.draw() love.update() These functions are called by the Love2D engine and are required to get any of our code to run at all. The load() function is called exactly once, when the game is started. The draw() function is called continuously once the game is running and is where any graphics code should be placed. The update() function is also called continuously and is where the state of the game should be updated. love.load() function love.load() xPos = 0 yPos = 0 playerWidth = 64 playerHeight = 64 playerSpeed = 200 submarineImage = love.graphics.newImage("resources/images/submarine.png") end The load() function is the perfect place for all kinds of initialization code. We start by defining some integer values for the position, size and speed of the player. We then load an image located on the hard drive - I'm using [this little pixel art submarine I drew](https://github.com/jeansberg/GreatDeep/blob/master/resources/images/submarine.png). This image will represent the player in our game. Note that Lua is a dynamically typed language so we don't need to declare any types for these variables. love.draw() function love.draw() love.graphics.draw(submarineImage, xPos, yPos, 0, 2, 2) end For now, our draw() function will contain a single line of code to draw the image at the player's current position. Normally you would only need the image, x-position and y-position parameters. The three last parameters are there because I wanted to make my tiny 32x32 pixel image a little bit bigger. The 0 means that the image will not be rotated and the 2s mean that the image's width and height are doubled. love.update() function love.update(dt) downUp = love.keyboard.isDown("down") or love.keyboard.isDown("up") leftRight = love.keyboard.isDown("left") or love.keyboard.isDown("right") speed = playerSpeed if(downUp and leftRight) then speed = speed / math.sqrt(2) end if love.keyboard.isDown("down") and yPos<love.graphics.getHeight()-playerHeight then yPos = yPos + dt * speed elseif love.keyboard.isDown("up") and yPos>0 then yPos = yPos - dt * speed end if love.keyboard.isDown("right") and xPos<love.graphics.getWidth()-playerWidth then xPos = xPos + dt * speed elseif love.keyboard.isDown("left") and xPos>0 then xPos = xPos - dt * speed end end The update() function will contain code for listening to keyboard input and moving the player around. You probably noticed that this function takes a parameter called dt. This is passed to the function by the Love2D engine and indicates how much time has passed since the last update() call. This is used as a multiplier to determine how much our variables should change. Without this adjustment, the speed of our game would directly depend on the speed of the computer running it! Input handling We begin by using the built in keyboard.isDown() function to check if any arrow keys are currently being pressed. We store this information in two variables. One will indicate whether the down or up key is being pressed. The other one will do the same for the left and right keys. If both of these values are true, it means the player will be moving diagonally. In that case we need to divide the speed value with the square root of two before we apply it to the x- and y-positions. Otherwise diagonal movement would be much faster than horizontal or vertical movement. Movement constraints We then check whether the down or up key is being pressed again (not the most optimal code, but sufficient for a tutorial!). If the down key is being pressed, we increment the y-position, since the y-coordinates start at 0 at the top of the screen. We use dt as a multiplier as mentioned above. It's not enough to merely check the player input however. We don't want the submarine to disappear below the screen, so we make sure the yPos variable is never greater than the height of the screen minus the height of the player (the player width and height are 64 pixels since I doubled the width and height of the image when drawing it). Similarly, we want to make sure that the submarine doesn't go above the screen so we check that yPos is greater than zero. The code for horizontal movement is very similar. Conclusion You can now use love.exe which comes with the Love2D install to run the game! Just make sure you give it the path to the folder containing your main.lua file as a parameter. You should be able to control the submarine with the arrow keys on your keyboard. If you're on a laptop without arrow keys, simply change the "down", "up", "left" and "right" parameters to some letter keys. In the following post we will take a look at some shooting, so stay tuned! Links Source code for this part Finished source code
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!