Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Porting projects from DBP

Author
Message
Digital Awakening
AGK Developer
20
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 7th Aug 2011 23:44
I've been in the beta test group since before the first beta. Sadly I had more time to code back when I joined than I have now. I thought I should share some of my experience in porting code from DBP to AGK. I started on a project in DBP while I waited for the beta of AGK. Right now I'm working on porting that code over to AGK. It's a simple board game I've designed myself. Well, I'm not doing a straight port of the code, I'm also adding a different touch interface I came up with later. I should say that it's not a difficult task. Number of lines and complexity will of course affect this.

AGK is very close to how DBP works. The two major things I've run into is that PASTE SPRITE is not included and text works differently. Drawing sprites manually by pasting them is not supported, for speed reasons. You can still use print to write text on the screen. But in AppGameKit you can create text objects that works similar to sprites.

When copying code from DBP you basically need to change every command. AppGameKit works pretty much the same but still most commands are called differently or at least have the spaces removed or brackets added. And the most common problem I run into is forgetting to change the brackets on the arrays. These would not be problems if you start a new project in AGK. This is all for the better IMHO.

I really like the way new sprites etc are created. I can now instantly store the sprite number into a variable and not have to bother handling the numbers myself. Take a look at the code below to see how I create the sprites for my board game.



baxslash
Valued Member
Bronze Codemaster
16
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 8th Aug 2011 17:33
Thanks, that's a nice insight. The code does look pretty... basic

Very similar to DBP.

DVader
19
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 8th Aug 2011 19:41
There is no paste sprite command? Eek I use that a lot. I also avoid using the animated sprites commands and change the images myself normally. You say paste sprite is not included for speed reasons? Odd, but I can live with it I suppose, as long as there is still paste image

Thanks for the little snippet. I am still deciding whether to get AppGameKit or not. I hope to convert over one or two projects myself.

http://s6.bitefight.org/c.php?uid=103081
KISTech
15
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 8th Aug 2011 20:15
It's been a little while since I've messed with sprites in DBPro, but if I recall you have to set the sprite every loop to make it show up, otherwise it just disappears, which led to the need for the paste sprite command.

AGK doesn't do that. It acts as a pasted sprite.

Example:

Before you enter the main loop, if you give the command,

SetSpritePosition(spriteID, 50, 50)

That sprite will stay there until you move it or delete it.

Airslide
18
Years of Service
User Offline
Joined: 18th Oct 2004
Location: California
Posted: 8th Aug 2011 20:40
Quote: "You say paste sprite is not included for speed reasons?"


Probably so that the internal rendering engine can batch drawing operations - if you can draw multiple sprites with one draw call to the GPU you save a lot of time versus doing it for each sprite individually.

I suppose it would still be possible with Paste Sprite if it deferred the actual rendering until Sync was called, but personally I think it just makes more sense for the sprites to be persistent (think of them as entities or objects), especially if you are giving your sprites a depth value since the sorting can be done when the sprite is added/removed rather than every frame.
Digital Awakening
AGK Developer
20
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 8th Aug 2011 23:22
DBP can do both versions. After learning that paste sprite wasn't in AppGameKit I rewrote parts of my code in DBP to use multiple sprites instead of pasting a single sprite. It's faster to have AppGameKit handle the drawing of the sprites then to do so manually.

You should consider using fewer tiled images rather then multiple images. It's my understanding that this is faster. AppGameKit supports atlas textures, basically you can have multiple images and tile sets within a single larger image. Haven't looked into how they are created yet, no need for my small projects.

There are currently no image manipulation commands. Basically you can load it from a file, load it from an atlas and delete it. And you can check if it exists as well as the with and height. Being able to create your own images within AppGameKit would be nice. I think TGC is focusing on more core command sets first.

If you want to code for multiple platforms and you like the way DBP works then I suggest start using AppGameKit now. That way you don't have to port over you projects later.

DVader
19
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 10th Aug 2011 13:44
Hmmm, no paste sprite, no box, line commands. So to make a simple box you would need to load in a ready made one, or make a loop to draw hundreds of sprites on the screen, assuming it is 1x1 pixels and fairly large. If paste sprite was available at least that wouldn't be so much of an issue. Pre made images sound pretty much the only way to go.
Is there no get image command or bitmap commands either?

http://s6.bitefight.org/c.php?uid=103081
KISTech
15
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 10th Aug 2011 19:35
No. No bitmap or image commands. It's all done with sprites.

However, to make a box from a 1 pixel image.

img = LoadImage("1pix.png")
spr1 = CreateSprite(img)
spr2 = CreateSprite(img)
spr3 = CreateSprite(img)
spr4 = CreateSprite(img)

SetSpriteScale(spr1, 10, 1)
SetSpriteScale(spr2, 10, 1)
SetSpriteScale(spr3, 1, 10)
SetSpriteScale(spr4, 1, 10)

SetSpritePosition(spr1, 10, 10)
SetSpritePosition(spr2, 10, 20)
SetSpritePosition(spr3, 10, 10)
SetSpritePosition(spr4, 20, 10)

This should create a 10x10 empty box. There are Box2D commands to take these sprites and join them so they'll move as one entity as well.

You are still probably better off using an image that is closer to the scale you'll want in the game and just resizing it as needed so you don't have to mess with all this, but I wanted to show that it can be done fairly easy.

Login to post a reply

Server time is: 2023-06-03 15:05:50
Your offset time is: 2023-06-03 15:05:50