AppGameKit Classic

AppGameKit Classic

Not enough ratings
Creating a simple sprite and making it move in AppGameKit
By thescenecommander
This guide walks the user through creating a simple Sprite object in AGK 2 and demonstrating how easy it is to get the sprite moving. It also begins to explore variables and how useful they are.
   
Award
Favorite
Favorited
Unfavorite
Adding a Sprite
Hi,

This guide shows how easy it is to add a simple Sprite object into an AppGameKit project and get it moving. Sprites are amazing powerful 2d objects, that can be moved, rotated, scaled, faded, collided with and a whole host of other effects. This simple tutorial starts with the basics and will be expanded on in depth in future guides.

You will need to copy and paste some of the media that is provided with AppGameKit as explained in the video. This media is located in your projects folder, in the Sprites/SpriteAnim1/Media folder.

As with the last example, you can find the resulting code below the video.


// Project: making a sprite move.
// Created: 2014-11-21

// set window properties
SetWindowTitle( "making a sprite move." )

// set variables
screenwidth=1024
screenheight=768
fullscreen=0

// set display properties for platforms that support windows, e.g., Windows or Mac.

SetWindowSize(screenwidth,screenheight,fullscreen )

// set display properties for mobile devices.

SetVirtualResolution(screenwidth,screenheight)


// Set up a sprite data

balloonsprite=1
balloonx=512
balloony=384
balloondirection=1

balloonimage=LoadImage("item0.png")

// create a sprite with ID that uses the balloon image
CreateSprite (balloonsprite,balloonimage)


// Main loop

do

// set the sprite position.
SetSpritePosition (balloonsprite,balloonx,balloony)

//move the balloon along the X axis by the amount specified by balloondirection
balloonx=balloonx+balloondirection

// check to see if the balloon is near the far right edge of the screen and if so, reverse direction
if balloonx+GetSpriteWidth(balloonsprite)>screenwidth
balloondirection=-1
endif

// check to see if the balloon is near the far left edge of the screen and if so, reverse direction
if balloonx<1
balloondirection=1
endif


Sync()
loop
7 Comments
Shin Navideño 13 Jun, 2019 @ 7:47pm 
U N A V A I L A B LE
Dalton RickmanT.TV 20 Jan, 2018 @ 6:57am 
its showing me that the video is unavailable
Dah Sweatah Shreddah 16 Jan, 2017 @ 8:31am 
Perfect!! thank you
thescenecommander  [author] 16 Jan, 2017 @ 6:48am 
Hi,

All media must be stored in a folder called Media, which should be located as a subfolder, in the same folder as the source code files. (the .agc)

I would guess that this will solve the issue for you.
Dah Sweatah Shreddah 16 Jan, 2017 @ 6:14am 
Hello!
I had a question with this guide (btw its awesome, thank you);
I made my "balloon" image with the item0 name as in the call stack and I get the message that it cant be found in the main.agc. Maybe I missed something, but could you help me in solving it? thank you.
Dwigt 27 Jun, 2016 @ 9:13am 
thanks!
Duke Sparrow 26 Nov, 2014 @ 7:51pm 
I appreciate that you go slow and explain each line item as you go. You make it very easy to understand and get started for us noobies. Keep up the great work!