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 / how do you create a game with a lot of entities without a ton of boilerplate code

Author
Message
yoel12344
2
Years of Service
User Offline
Joined: 5th May 2021
Location:
Posted: 8th May 2021 16:22 Edited at: 9th May 2021 20:06
edit: i dont want a drag and drop tool or a level editor (i hate both concepts), and im not a lazy person who dosnt like to code ....
i just wanted to know why agk dosnt have refrences (it dosnt it just copies vars assigned to other vars...) i also wondered if you could do somthing more modular with user defined types (again apparently not)
please don't offer me to go use game maker or unity.


how do you make a complex game with a lot of entities, screens gui etc.

you have types and all but you dont have a constructor so you have to init everything by hand.

you don't have references (every variable is its own copy of the data you give it).

you have to, remove /add / update, etc everything by hand (or is there a secret modular reusable way to do this?).

how do you do it without a lot of boilerplate code?

like:

create an array for bullets, enemies, powerups etc.

create a loop to update each

hide them/remove them when you go to a different screen (how do you do screens in the cleanest way?

and they say "so it will be a minimalistic language for beginners" like really? even in javascript, you can use vars as references to other vars.

in agk if you assign "very_long_name.array[i]" to lets say "a as xtype" it will create a copy, like really? why do i need a copy of the same data when all i want is a reference/cleaner code to manipulate a very long type with an array.
and it dosnt say anywhere in their guides its that way.


i dont know how they expect you to have a big project that is not total spaghetti code with that.

if anyone has an example of a big project (or how to structure such a thing) with agk basic.

if i wanted a c++ engine i would have gotten a free one.

in blitz 3d i ported my framework no problem, here its just wierd please give me your input.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 8th May 2021 20:32
Quote: "how do you create a game with a lot of entities without a ton of boilerplate code"


You use GameMaker or Godot, you can not expect to pick up a code tool like AppGameKit and have tonnes of usefull code fall out of the box you build this up over time, your bullet example, one you write a system for firing a bullet, if your smart and write a modular system you now have a reusable bullet firing system that can be dropped in any game ...

over time the amount of boiler plate code you will need will become less and less as you establish a library of includes, bullets, player movement scripts and functions

AGK is a coders tool, a game framework, if you want to drag a load of images into a frame and click a button to see the results then AppGameKit is not the tool for you, you want a game engine, most people want the latter, I love AppGameKit and I don't even make games, I just get a kick out of making it do what it doesn't say on the tin

as for arrays, variables and pointers, remember Javascript is typeless, agk is not, you can not assign a string variable to a float value in almost every other language (bar Javascript and Lua off the top of my head) so all agk is asking of you is that you define the var type, you can then set it to your type array



if you are adding data it has to be processed somehow, how you handle that is up to yu but I like to ...


As for spaghetti code, thats on you my friend, if your code is a mess, you made it (unless its C++, then its just ugly!)

avoid spaghetti code by making vary targeted functions and separate code into sections, yes some kind of class system would be nice in AppGameKit but as there isn't so you simply have to "fake" it, well structured functional code is a thing of art so embrace it, lol
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 9th May 2021 05:56 Edited at: 9th May 2021 06:08
I'm not the best coder but here's how I go about it in my half-finished game Strawberry Quest. (full source included!)
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 9th May 2021 06:15
Quote: "you don't have references (every variable is its own copy of the data you give it)."


No, each Variable is merely a Reference... AppGameKit handles Memory Management., so let's say you have:

Type Vec3 : X# : Y# : Z# : EndType
A As Vec3 = [ 0.0, 1.0, 0.0 ]
B As Vec3 : B = A
C As Vec3 : C = B

In said scenario ONLY A is actually the Root Data Reference (thus will contain the addresses for said data in A.X# A.Y# and A.Z#
The others are going to be Deferred References.
As long as Data Types Match (i.e. same Fundamental Data Type., String / Integer / Float; or User Defined Type) then they will simply de-reference.

Now an exception to the above is when you pass into Functions., then these are created as Data Copies UNLESS you specifically use the [Name] Ref As [Data Type] ... but even then this is presently limited to UDT or Arrays.
I think they should expand this to Fundamental Data Types as well; but then I think they need to expand the Fundamental Types to allow for 8/16/32/64 bit Variable Depth and denoting Signed / Unsigned (but then I'd prefer less Abstraction and more Explicit support)



Now beyond this., I'm actually not entirely sure what you're saying.
You know what would help; would be examples of what you're talking about from another language... then someone can say "Yes this is possible" or "No this isn't... but here's an alternative"
Several of your points don't really make sense.

This isn't a Text or Twitter Conversation; you're not limited by the number of Characters you can use; so be verbose and give examples.
Because what it sounds like to me is that you just want to use Unity, Godot, or Unreal Kismet; to create a template entity then just drag-and-drop a single command to make it work as a Particle Effect or Bullet or such.

AGK is a Programming Language... albeit Scripting, so while functionally it's capable; performance wise... yeah don't be thinking you'll be handling Thousands of Entities.
Want to see what I mean, go look at my conversion of a Software 3D Engine; what killed completing that was PERFORMANCE not Language Capability.
As such, as I always say. AppGameKit is best for "Small" Projects.

You want to do bigger and more ambitious things... look at Dark BASIC Professional instead.
But as noted, it doesn't sound like you want a Programming Language IF you don't want to do things yourself.
Even in Java you're doing A LOT of Boilerplate Code, arguably more in most situations.
yoel12344
2
Years of Service
User Offline
Joined: 5th May 2021
Location:
Posted: 9th May 2021 11:27 Edited at: 9th May 2021 15:49
wow i dont understand how you got to the conclusion i want drag and drop, i despise drag and drop, aka visual programming, it disgusts me, i dont even like 3d scene builders. unity sucks, and i never saw game maker as an option.

im a programmer close to 10 years, i mostly did database based web aplications.

i started game programming with flashpunk an as3 flash framework, the competitor of flixel (most complex thing i did lately is to implement flow field algorithm for an rts game its actually a nice algorithem).

it(flashpunk) uses entity (a as3 class) and entity derived/extanded class as "actors"/game objects, an entity has most things you need for game objects : movment (with solid hit detection) hit collision detection (box and pixel based and even raycasting), rotation,alpha, basic maths (angel between point/entity, distance) sprite/image manipulation/animation (including tween), input handling,etc etc.

each entity has a type so you can get entities with "get by type" or collide by type.

thers also world, itsl like a screen, each world holds entites, while non active worlds entites are not active or visable, you change world to move between screens.

for example a pong game with this framework:

worlds: start screen, game screen, game over

entities:
paddle
ball
score
buttons

edit:the big thing is that its oop meaning a class encapsulates data and functions (methods) so all you need to do is : world.add(some_entity) , and dont worry about it the world will update it as it keeps a list of entites, and to remove its as easy world.remove(some_entity), no need to loop anything update a list/array,display object like sprite remove does it all.

btw agk has this when you add or remove a sprite(and images and sounds etc), why dont they make a way to do this with user defined types? that would make my life much easier with less boilerplate code.

i can do all this without that framework, as proof over the years i ported it(flashpunk framework) to at least 10+ engines and languages (i know it very intimately):

my first attempt after i was told flash is dead(decleard dead), there were no class in js yet so i used prototypes (the engine is dom based):

https://github.com/yoel123/yoel-html5-game-engine-tutorials

later i ported it to phaser js:

https://github.com/yoel123/yoel-phaser-js-framework

and then to java with slick 2d (java has oop):

https://github.com/yoel123/yoel-java-slick2d-framework

it lacked mobile so i ported it to corona sdk, lua has oop, but its a bit clumsy:

https://github.com/yoel123/corona-sdk-picking-sticks

i will also make a picking sticks for agk.

i also ported it to unity (i dont have the files).

ported to naalaa ( a basic dilect):
https://github.com/yoel123/naalaa-avoider-game

naalaa has types but no oop but i manged

blitz 3d port:



and fnaly the agk port:

yengine.agk:

main.agk (you will need ph.png placeholder in media flder):





im still pissed thers no proper refrence variables like:

a = "bla"
b = a
b = b + " holubalu!"

print(a)//prints bla
print(b) //prints bla holubalu!

dosnt seem anoying? lets see

im_a_very_long_object_array[i].pos.x = 5
//im a short var to refrence the line before for readabilety and fun
ex = im_a_very_long_object_array[i].pos.x //short for entity x
speed = 1
ex = ex +speed

print(ex)//prints 6
print(im_a_very_long_object_array[i].pos.x) //prints 5.....why me why

so i have to use im_a_very_long_object_array[i].pos.x to update that entities pos (or create a function for that) .

agk seems like a very powerful toll with many platform support and everything you need to make a game out ob the box the basics and luxury features.
i would prefer to use its basic scripting language (if i wanted cpp i would have used a diffrent free engine).
somtimes simple is better for faster devlopment.
but no oop is very hard for somone who is very used to and fond of oop.
again it dosnt even have proper references.

if somone has an advise or a workaround (or a feature i dont know about) it will help me a lot.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 9th May 2021 19:41
If you want to drag and drop your sprites etc this is one of the reasons people use the studio version of agk

The alternatives are using any one of the editors available
search the forums people share them there are 3d

for 3d https://forum.thegamecreators.com/thread/227129
or this one https://forum.thegamecreators.com/thread/225456

for 2d https://forum.thegamecreators.com/thread/223121

or could make your own there is a bare bones 3d one here i have shared the code https://forum.thegamecreators.com/thread/222027?page=3
there are lots of them on the forums and with the beauty of json files it makes for much cleaner code

the editors you chose is a personal preference but often customizing one to your own personal requirements is best do a search of placement in the forums and you will find a heap of 2d ones


fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 9th May 2021 19:44 Edited at: 9th May 2021 19:56
often developing software requires developing custom tools here is a game i am working on it uses a heap of tools but shows clearly
a track editor and terrain editor that had to be made aswell as the game both of which were created in agk



another one by me a 2d placement editor with source very early stages https://forum.thegamecreators.com/thread/219932

fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 10th May 2021 00:22 Edited at: 10th May 2021 00:24
Quote: "i despise drag and drop, aka visual programming, it disgusts me"


Visual scripting, sure I got you covered



I do hate this OOP snobbery, OOP guys pick up basic and do nothing but moan about it, if you don't like functional programming which from your posts is quite obvious then go back to OOP.

Attachments

Login to view attachments
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 19th May 2021 03:07
The reference assignments is kind of something you just get used to to be honest. A good text editor with auto completion makes it less an issue since you can just type a few characters and let the editor expand it to the long array name for you.

There's also some tricks you can do with constants - which aren't really the same thing as a const but are actually find:replace preprocessor tokens

Also, a constructor is still just a function at the end of the day, you can set up a function and call it to handle initializing an object, its an extra step, but does the job



Posting from phone, there are probably some minor syntax errors sorry




http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
jd_zoo
5
Years of Service
User Offline
Joined: 12th May 2018
Location: Nova Scotia
Posted: 21st May 2021 01:56
As someone who loved Action Script 3 I have found AppGameKit to be the best thing since. You either get used to the idiosyncrasies or they drive you nuts and you move on. But I don't think a perfect solution exists... Although the syntax is basic this is an OOP language, and you can pass data as a reference https://www.appgamekit.com/documentation/guides/types_004.htm

Login to post a reply

Server time is: 2024-04-20 09:55:34
Your offset time is: 2024-04-20 09:55:34