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.

Newcomers AppGameKit Corner / [STICKY] The Useful Community Functions Project

Author
Message
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 21st Mar 2012 18:48
Here is a pretty basic function but im guessing someone may find it usefull. Basicaly it will turn a sprite to a cirtain point.

IBOL
Retired Moderator
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location: @IBOL17
Posted: 24th Mar 2012 18:46 Edited at: 24th Mar 2012 18:52
lots of functions with descriptions, from my work on my 7drl (seven day roguelike)

(according to top post, there are over 200 functions. i tried downloading and found only about 20-50. so please forgive me if some of this work has been duplicated. that is not my intention)

this function is used for reading text lines from data files, specifically ones with 'line headers'
if your monster data was in file # 1, and if this was the data in the file:
MonsterStrength : 10
you would want to cut off the first 18 characters to get your value, so
ReadFileItem(1,18)
it also allows lines that start with ` to be not read, so you can put other information in your data files.
the actual return type is String, so you'd want val(readfileitem(1,18))


this function will make sure that a particular value remains between 2 values.
x=bind(x,1,10)
x will always be between 1 and 10


this will add zeroes to the beginning of a score (like if you want your score to be 6 digits,
and it's only 123, do score$=pad(str(score),"0",6). this will insert 0's at the beginning.
it can add any string (b$) to any length(p) to any string (a$).


compilation sprite code. index number, image #, x,y,depth
has several checks to stop failures/crashes


a text compilation function.
id#,string,x,y,size,alignment


checks a range of sprite numbers to see if the pointer is above them
it does not actually detect the 'press' event, but it will return the
sprite number that the pointer is over, if between the ranges 'lo' and 'hi'


this functions takes a number and returns it as a string with commas 1656323 comes back as 1,656,323.


this function deletes sprites betweeen the id range 'a'-'b'.
it checks to see if they exist first, so it's safe.




this sets a range of text strings a-b to null ""
if you want to clear your displays without deleting them


if you use a lot of keypresses, this function might help avoid unintentional chains of the same key
it works by ascii value. if the player presses Q, call WaitForUnPress(81)
and the system will hold until the key is released. from what i found, sync is necessary to detect releases.


this is a D&D inspired function. it rolls a y-sided die x # of times, and returns the value.
xdy(3,6) returns a value between 3-18. xdy(2,20) yields 2-40.


this sets a large number of sprites (L-H) either visible(1) or invisible(0)


Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 29th Mar 2012 16:26
Enhanced Sprite and Text Colour Commands

They work the same as the normal setSpriteColor() and setTextColor() commands, but using a value of -1 for any of the values will leave that value unchanged.

A feature worth including in the language perhaps?
Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 31st Mar 2012 14:01
Sorry guys, I'm behind on this project because I've been writing the Tier 1 android tutorial for TGC, in order to be as fair as possible to people I want to get the next official release out before I run the lottery, this allows me to check all the submitted functions, check for duplications and compile a final list.

The date for the lottery has been moved back to the 7th of April.
Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 4th Apr 2012 18:01 Edited at: 4th Apr 2012 18:02
I'm in the process of updating the documentation now, the documented commands have gone up from 48 to 71. Once this is updated to a reasonable level I can then generate the list of contributors based on the amount they contributed and run the lottery program (me printing out the names, shaking them in a box, and randomly picking one ).

Meanwhile official release 0.0.1.3 is up, you can download it while I work on 0.0.2.0!

There's been a major structural change to the way UCF works now, that single UCF.AGC file was getting ridiculous and it was increasingly harder and harder to find and organize. So I've put the functions into a sub-directory and split the commands up into their own category files. It now looks like this:



DOWNLOAD HERE

Attachments

Login to view attachments
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 5th Apr 2012 02:52
Quote: "There's been a major structural change to the way UCF works now, that single UCF.AGC file was getting ridiculous and it was increasingly harder and harder to find and organize. So I've put the functions into a sub-directory and split the commands up into their own category files."


Good. That's much more sensible.

I've forgotten - what do you win if you win?

Clonkex

Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 5th Apr 2012 17:33
check the title of the post
Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 6th Apr 2012 05:57 Edited at: 6th Apr 2012 05:58
Heres version 0.0.1.9

I'll add IBOL's functions and scan through the DF functions tomorrow and bring this project up to a round 0.0.2.0 then I'll get the lottery list compiled and video the results and post it to youtube and here.

Good luck, and thanks for supporting this project so far!

Attachments

Login to view attachments
Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 7th Apr 2012 00:05 Edited at: 7th Apr 2012 00:06
Release 0.0.2.0 is here!

109 documented functions!

Now it's time to run the lottery! The whole amazing event will be recorded and will be uploaded soon. The winners prize will be issued within 48 hours!

Good luck all!

Attachments

Login to view attachments
Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 7th Apr 2012 01:48
Lottery draw!
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 7th Apr 2012 01:56 Edited at: 7th Apr 2012 01:58
Congratulations to the winner - very deserving if I might say so.

No I'm not going to spoil it, suffice to say it wan't me

Can I be the first to point out that your random number generator has a right handed bias, I can't help but feel that lefties like me were robbed

Only kidding, well done

Shame about the egg
The Slayer
Forum Vice President
14
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 7th Apr 2012 02:46
Cooooooooooooongratz, Hodgey!
You lucky dude!

Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 7th Apr 2012 03:13 Edited at: 12th Jun 2012 00:20
Oh wow! This has brightened up my day! A big thank you to you Daniel and to TGC! You also pronounced my name correctly which none of my family was able to do.

I think I'll save the vouchers for 'major' AppGameKit upgrades. Do they have an expiry date?

Quote: "Congratulations to the winner - very deserving if I might say so."

Thanks Marl! Everyone here is deserving of it though. You'll have a stronger chance next time as I don't think I'm allowed to win twice.

@ The Slayer: Thanks man!

It's been a while since I've submitted a function and I'm out of ideas so, any ideas?

Edit- HighScore Functions

Dependencies


SetUpHighScores( HighScoreSize )

Creates two arrays to save the names and scores, and creates a variable to store the size of the arrays.

AddToHighScores( Name$, Score)

Adds the Name and Score to the highscore lists if the score is large enough.

HighScoreNameReturn(Index)

Returns the name at the index given (0 = highest). Out-of-bounds indexes are adjusted to be compatible with the highscore arrays.

HighScoreValueReturn(Index)

Returns the score at the index given (0 = highest). Out-of-bounds indexes are adjusted to be compatible with the highscore arrays.

Demo:


MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 7th Apr 2012 13:41
haha that made my ay for certain

congrats Hodgey... not a difficult name to pronounce if I may say so...

Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 7th Apr 2012 15:22
Quote: "congrats Hodgey... not a difficult name to pronounce if I may say so..."

Thanks MrV! People tend to pronounce the 'o' with the sound of 'oe' e.g poke. It has that long 'o' sound when I intend for the short 'o' e.g wok.

I just made a small amendment to my AddToHighScores function.

Impetus73
12
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 7th Apr 2012 17:42
Just got an idea. What if people have functions they would like to see, but does not know how to make.. Can we post suggestions here, so someone will Pick it up and add it to the project?

----------------
AGK user - novice
Did Amiga / AMOS programming in the 90's, just started programming again with AGK.
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 7th Apr 2012 17:48 Edited at: 7th Apr 2012 17:52
Quote: "What if people have functions they would like to see, but does not know how to make."

That would be "Useful Community Ideas" not "Useful Community Functions".

I'll start;

"can someone write a function which takes care of all the programming I need in my game"

Seriously though, I think something like that should be in a separate thread, Daniel has enough to pick through here as it is.

If you think it has merit, why not start one?

"If you build it, they will come!"
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 7th Apr 2012 18:30
Congratulations Hodgey!

Also, I have always pronounced your name with a short 'O' sound, like "got". I can't see why anyone would pronounce it with a long 'O' sound like "goat"...

My favourite part of the video was the cutting part. Didn't you fingers ache terribly, Daniel?

Clonkex

Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 8th Apr 2012 09:19
Quote: "What if people have functions they would like to see, but does not know how to make.. Can we post suggestions here, so someone will Pick it up and add it to the project?"

Quote: "That would be "Useful Community Ideas" not "Useful Community Functions"."

However, it can be argued that in order to build useful functions for the community, we need to know what the community wants.

Apart from the lottery draw and latest release, things have been somewhat quiet around here lately so maybe a few ideas/requests won't hurt.

Out of curiosity, what did you have in mind Impetus?

Quote: "My favourite part of the video was the cutting part."

That was pretty awesome. I love the time-lapse effect.

Impetus73
12
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 8th Apr 2012 10:56
Oh, I did not have any requests in mind, I just got the idea

----------------
AGK user - novice
Did Amiga / AMOS programming in the 90's, just started programming again with AGK.
Nokiaqd
14
Years of Service
User Offline
Joined: 31st Aug 2009
Location:
Posted: 9th Apr 2012 07:58
Generally very good idea!
So many goodies in such a short period of time, no programming forum did not give so fast ..

Congratulations to the winner!

badablog.ru - bada developer
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 9th Apr 2012 12:25
Quote: "That was pretty awesome. I love the time-lapse effect."


Me too Wouldn't have been anywhere near as good without the music and the time-lapse.

@Daniel:

You couldn't have sounded any less enthusiastic when you announced the winner's name if you'd tried! "And the winner is....Hodgey...." Sort of like you were thinking, "Oh, only Hodgey..." Just kidding

Clonkex

Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 9th Apr 2012 23:02
Quote: "You couldn't have sounded any less enthusiastic when you announced the winner's name if you'd tried!"

He could have been a bit tired. I would be after cutting out that many names.

Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 9th Apr 2012 23:26
You're just sticking up for him 'cos he's still got your cheque
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 10th Apr 2012 00:26
Quote: "You're just sticking up for him 'cos he's still got your cheque"

Actually, I got it about 12 hours ago but I see how it is. I've got a little function for you Marl, enjoy.


Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 10th Apr 2012 05:01
Lol, I like that!

Clonkex

Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 10th Apr 2012 12:19 Edited at: 10th Apr 2012 12:20
Quote: "You couldn't have sounded any less enthusiastic when you announced the winner's name if you'd tried! "And the winner is....Hodgey...." Sort of like you were thinking, "Oh, only Hodgey..." Just kidding "


All good game show hosts put in a dramatic pause! Also I'm Marvin the depressed robots illegitimate offspring, so be glad that you didn't get a 20 minute rant on the unfairness of life the universe and everything. Oh and doors that sound too happy when they open.

Brain the size of a planet and they having me cutting out little names from paper...
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 10th Apr 2012 13:09
Ahahahahahaha

Marvin

ahahahahahaha

you made my day Daniel

Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 10th Apr 2012 16:21
I want to win something!!

I've recently completed some code to automatically wrap text around the current device width. It'll be easy simple to change this to manually set a wrapping width too if so required.

The snippit is quite large, but includes everything required to successfully run and is completely stand alone.

I hope you like it!



Paypal dispute? Meh!

My signature is NOT a moderator plaything! Stop changing it!
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 10th Apr 2012 16:25 Edited at: 10th Apr 2012 16:30
Ok, I felt even more generous! Now I've included the command to set the width to whatever you want.

I must be the greatest person ever!! lol



Any requests??

"here is a an expression to remember - He who has the gold makes the rules."
Paypal disagreed!
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 10th Apr 2012 17:02 Edited at: 10th Apr 2012 17:10
Well if it's text functions you want, here's a couple if tiny ones.

TextFillWidth( thisText ) will resize a text object to fill the screen width
TextCenter( thisText ) will put it in the middle of the screen

any text object, any size, any resolution, no variables used


Full Project

Result

edit: add image / formatting

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 13th Apr 2012 13:11
Congratulations Hodgey! You have certainly provided some very useful functions and deserve the win

Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 13th Apr 2012 19:10
Better than my text wrapping functions!?!?

"here is a an expression to remember - He who has the gold makes the rules."
Paypal disagreed!
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 14th Apr 2012 00:59
Quote: "Better than my text wrapping functions!?!? "

I have the gold!

@baxslash: Thanks! How far did you get with your waypoint/pathfinding functions?

Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 14th Apr 2012 02:56
Quote: "I have the gold!"

Hmmm, that's not what paypal told me when they returned my fat cheque!

"here is a an expression to remember - He who has the gold makes the rules."
Paypal disagreed!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 14th Apr 2012 23:57
Quote: "
@baxslash: Thanks! How far did you get with your waypoint/pathfinding functions?"

They're on the backburner. Funny, I was thinking about those today on a 4 hour drive home

Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 15th Apr 2012 03:06
Quote: "They're on the backburner. Funny, I was thinking about those today on a 4 hour drive home"

I can be psychic occasionally. The reason I ask is because I have an idea (still in the concept stage) for path finding. When I find the time, I might write up a few prototypes.

qwe
20
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 8th Jun 2012 03:44
i don't understand this function fully:
what does the code look like, that calls the function? how do you accept two return values?

dim velocity[2]
velocity[] = calculateVelocity(angle#, speed#)

do you do that?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 8th Jun 2012 10:35
@qwe, you'd need to give it a position in the array to assign to as well or assign it to a variable:


bitJericho
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 16th Jun 2012 06:02 Edited at: 16th Jun 2012 06:38
Woo perlin noise functions. Written for the demo version of AppGameKit, cuz I haven't bought it yet Untested in paid version:



Sample code:


baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 16th Jun 2012 10:11
Excellent!! I wanted to look at doing this at some point but now I don't have to

These can be used for so many different applications. Thanks lot Mr.President

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 20th Jun 2012 18:29
An additional string function that works alongside the "CountStringTokens" and "GetStringToken" functions. This simply removes a specified token from the string and returns the result:



this.mess = abs(sin(times#))
Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 25th Jun 2012 14:47
Don't forget to submit new functions! Remember the next prize draw is coming up.
Scary Little Rabbit
14
Years of Service
User Offline
Joined: 4th Aug 2009
Location: Chelyabinsk, Russian Federation.
Posted: 11th Jul 2012 10:22
sorry for offtop, but i want to invite you try this. thank you.

error #0101:
- english language conflicts with a brains of this rabbit.
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 15th Jul 2012 11:56
Unfortunately, no new commands this time around - sorry

Actually working on some stuff but it's ages from being finished.

Clonkex

Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 15th Jul 2012 12:01
Just read the post about Daniel being Marvin's offspring - can't believe I missed it! This is what I would have said had I seen it earlier:

LOLOLOLOLOLOL (and yes I know it looks awful having that many "lol"s in a row, but it gets the message across) that's brilliant!

*happy cuz I got L4D2 and ME2 today*

Clonkex

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 9th Aug 2012 13:24
Can I just say thanks to Scraggle for his Lerp / Hermite functions. I use them a LOT now (for animated buttons / animation sequences / for my character animation program / countless other things) and although I know there are lots of examples of this on the net it's nice to have a solution provided for so many different problems in one neat package.

They deserve a prize of some sort too

Thanks Scraggle!


this.mess = abs(sin(times#))
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 10th Aug 2012 11:41
I second that, I even wrote up a news feature about them.

Has anyone been able to work out how to alter the wave at the end of the Berp? I can adjust the depth of the overshoot (see above article) but not the amount by which it wavers back and forth.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 10th Aug 2012 11:42 Edited at: 10th Aug 2012 15:42
I haven't tried but I'll take a look...

EDIT: Here is the version of the lerp functions I'm currently using. It seems I already worked out how to increase the size of the berp already using the "amount" parameter added here



this.mess = abs(sin(times#))
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 10th Sep 2012 18:56 Edited at: 17th Sep 2012 19:34
This function will deflect a dynamic actor from a sensor based on the angle of the sensor. Works well for long thin sprites(sensor) which can be used as a pinball paddle or something similar.



As far as I am aware, there are no kinematic functions. I have submitted a request, if added then this kind of custom collision should be unnecessary.


EDIT: You can set your sprites as kinematic upon creation, oops. The above command may not be useful then, 2 hours wasted
Have not tried kinematic yet but it should suit my needs.

Login to post a reply

Server time is: 2024-04-24 06:34:45
Your offset time is: 2024-04-24 06:34:45