Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon
22. March 2016

 

This page is in support for the video tutorial on using Sprites/Images in Love as part of the GameDev For Complete Beginners tutorial series.  It contains the code and images used in the tutorial.  There is also a copy of the tutorial embedded below.

 

Images

The graphics are from this pack of images, made transparent using this process.

ALC-17AttackChoppers

 

Simply right click and save to your project directory.

 

Source Code

Drawing an Image

local imageFile

function love.load()
    imageFile = love.graphics.newImage("ALC-17.PNG")
end

function love.draw()
    love.graphics.draw(imageFile)
end

 

Using a Spritesheet

local imageFile
local frames = {}

local activeFrame
local currentFrame = 1
function love.load()
    imageFile = love.graphics.newImage("AttackChoppers.PNG")
    frames[1] = love.graphics.newQuad(0,0,128,64,imageFile:getDimensions())
    frames[2] = love.graphics.newQuad(128,0,128,64,imageFile:getDimensions())
    frames[3] = love.graphics.newQuad(0,64,128,64,imageFile:getDimensions())
    frames[4] = love.graphics.newQuad(128,64,128,64,imageFile:getDimensions())
    activeFrame = frames[currentFrame]
    print(select(4,activeFrame:getViewport())/2)
end

function love.draw()
    --love.graphics.draw(imageFile,activeFrame)
--[[    love.graphics.draw(imageFile,activeFrame,
        love.graphics.getWidth()/2 - (select(3,activeFrame:getViewport())/2) * 2,
        love.graphics.getHeight()/2 - (select(4,activeFrame:getViewport())/2) * 2,

            0,
            2,
            2)
]]--
    -- draw image 4x size centered
    love.graphics.draw(imageFile,activeFrame,
        love.graphics.getWidth()/2 - ({activeFrame:getViewport()})[3]/2 * 4,
        love.graphics.getHeight()/2 - ({activeFrame:getViewport()})[4]/2 * 4,
        0,
        4,
        4)
end

local elapsedTime = 0
function love.update(dt)
    elapsedTime = elapsedTime + dt

    if(elapsedTime > 1) then
        if(currentFrame < 4) then
            currentFrame = currentFrame + 1
        else
        currentFrame = 1
        end
        activeFrame = frames[currentFrame]
        elapsedTime = 0
        end
end

 

 

The Video

Programming , ,

19. December 2015

 

You may have noticed this year that GameFromScratch was increasingly active creating videos on YouTube.  Inititally it was pretty much a 1 to 1 relationship with GameFromScratch.com.  That is, for every video on YouTube, there was a corresponding post here on GFS.  Recently however I have found some topics are more video friendly or more text friendly and that 1 to 1 relationship doesn’t always exist.  Therefore I’ve decided to launch this weekly recap series which simply brings together the last weeks YouTube videos in a single place.

IMG_1826

 

 

This week saw the launch of a new video series, Bad GameDev!  No Cookie!  Which looks at game development mistakes in actual games.  So far there are two videos in the series. 

The first series looks at the bad 3rd person camera in the on-rails iOS shooter Freeblade.  Unfortunately Camtasia picked up the wrong mic for voice over in this video, so the audio quality is horrid.  Sorry about that.

Bad GameDev! No Cookie! Game Design Mistakes: Freeblade

 

Next in the series we looked at Space Marine and show the folly of a bad FoV.

Bad GameDev! No Cookie! Game Design Mistakes: Space Marine

 

We also had 3 additions to the GameDev Toolbox Series, an ongoing video series showcasing the tools of the game development trade:

Texture Packer

Sculptris

Tiled Map Editor

 

We also took a quick look at the AirPlay/Google Cast desktop server, Reflector2

Reflector2

 

And of course the recap of last weeks game development news.

Week 4 News Recap

General

18. September 2015

 

The following is a video showing the process discussed in this earlier tutorial.  For all the source code mentioned, see the earlier link.

 

 

The video is also available in high definition here.

Programming , , ,

11. August 2015

 

Welcome to the very first tutorial in the Paradox Game Engine tutorial series, this section is going to cover installation and getting started.  The process is in reality incredibly straight forward, so this should be fairly short.  If you are unfamiliar with the Paradox Game Engine, consider starting here for an indepth review of Paradox’s functionality.

 

As with most tutorials on GameFromScratch, this one is also available as an HD video.

 

Getting Started

To get started, of course you are going to need download a few things.

 

Either version of Visual Studio will work.  If you don’t have a license, remember the community edition is free for small teams and people who make less than $1million per year in revenue.  You don’t specifically need to have Visual Studio installed, Paradox actually ships a copy of MSBuild and the .NET framework includes the C# compiler.  If you want to instead use your favorite text editor, that is an option.  These tutorials are all going to assume you are using Visual Studio however.

 

If you are going to be using Visual Studio, and don’t already have it installed, make sure it is installed before installing Paradox, as part of the Paradox installation will install a plugin to Visual Studio.  I am not going to go through the Visual Studio installation process; however if you choose strictly default settings, it will work out just fine.

 

Once you have Visual Studio installed, make sure you run it at least once to allow it to do some late step configurations.  This may not be strictly necessary, but better safe than sorry.

 

Next run the Paradox Installer you downloaded earlier.

image

 

The install process is extremely straight forward, basically just asking you which shortcuts you wish to create.  Once complete, the Paradox Launcher will be run.  This is the application you use to create new or open existing Paradox projects, as well as managing which version of Paradox you have installed:

image

 

It will now detect that you don’t have an SDK installed ( assuming you don’t have a prior install ), when prompted, choose yes:

image

 

It will then ask if you wish to install the Visual Studio integration, again click yes:

image

 

Your Paradox install should now be complete.

 

Creating Your First Project

 

Now that Paradox is installed and configured, let’s create our first project.  In the Launcher, click the big purple Start button,  your actual version number could obviously differ from mine.

image

 

This will launch the New/Open Project dialog.  You may notice there are several examples you can load.  In this case we are going to create a new project instead. 

image

 

The only thing to be aware of here is when naming your game, be sure to use a C# namespace friendly value.  For example, Game3D works, but 3DGame will work here, but then blow up when you get to the project in Visual Studio.  For a very detailed description of what’s allowed and what’s not in a C# variable see here.  Simple rule of thumb however, don’t start with a number or punctuation other than an underscore and keep away from oddball characters and you should be good.

 

Once you click the Select button, you will be taken to another dialog:

image

 

Here you can choose which platforms you want to support.  You may notice that Windows Store and Windows Phone are both showing “The Requirements to build for this platform are not met on this machine”, that is because I do not have the proper signing keys configured.  The value “Windows 10” might also be a bit confusing, as a normal “Windows” project will run just fine on a Windows 10 machine.  In this case “Windows 10” refers to the now renamed Universal apps, that enable your code to run on desktop and mobile Windows platforms.  It’s also important to note that Android and iOS development require a Xamarin license.

 

The final options are for configuring the starting graphics configuration as well as the starting orientation.  Once done, click OK.  This will then launch Paradox Studio:

image

 

Paradox creates a simple preconfigured scene for you.  Most importantly it sets up all the graphics configuration for you.  Feel free to delete everything from the scene, although I would recommend keeping at least the camera initially.

 

You can now test that your Visual Studio integration works properly.  In the toolbar you should see this:

image

 

If you have multiple versions of Visual Studio installed, you should be able to select which one you wish to use.  In my case I have only Visual Studio 2015 installed.  Either click the version you want to run, or the toolbar Visual Studio icon for the default.   Visual Studio should now open with your project displayed:

image

 

Looking in Solution Explorer you should see a project ending in .Game, as well as one project per platform you selected.  The .Game project is where the majority of your game logic will go, while platform specific initialization code will go in each platform project, if required that is.  You should also now see a new menu Paradox if you install completed correctly:

image

 

That’s it.  Paradox is now up and running and you’ve created your first project.  Stay tuned for the next part where we take a tour of Paradox Studio.

 

The Video

 

Programming , , ,

10. July 2015

 

A new Blender tutorial series was just released here on GameFromScratch.com.  It has actually been under development for a couple months, I have just finally put together a table of contents page for it.

 

The series is called Learning Blender, One Hour at a Time and the entire premise is to break learning Blender into one hour chunks and cover as much as possible in each hour.  Currently there are video tutorials for introduction, modelling, texturing and animating.  There will be one last video on rendering released shortly.  Combined, the five hours of instruction should give you all the details you need to get started learning Blender.  Additionally there are a few simple tips and trick videos we have published, they have been gathered together into one place for the first time.

 

Below is just a screenshot of the actual series table of contents.  Click here or the image below to go to the actual tutorial.

image

 

Enjoy!

Art , ,

 

Month List

Popular Comments