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
BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 4th Nov 2012 22:47
Has anyone had any luck with Berps and bounces?

When I use values of x from 0 to 1, as the graphs suggest, I don't get the same result. The bounce only bounces onces, and the berp only berps once. There is no repetition.

Hodgey
9
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 5th Nov 2012 01:11
Quote: "Has anyone had any luck with Berps and bounces?"

I just had a go at writing my own bounce function (in C++) and got it working as expected. For a bounce, basically all you need is to take an absolute value of a sine wave (bouncing effect) with a decreasing amplitude (lowers the height of the bounce). I haven't looked deeply at Berp.

Are you able to produce a small code snippet?

BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Nov 2012 09:47 Edited at: 5th Nov 2012 09:50
Thanks Hodgey, I'm using the bounce in this thread:



But this is my result, feeding values of x from 0 to 1 (I multiply my return value by 30)



The original post from Scraggle shows this:



Attachments

Login to view attachments
Hodgey
9
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 5th Nov 2012 11:25
Try this:



BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Nov 2012 12:28
Hodgey has helped me create a more sophisticated bounce routine. Here it is, you can supply the number of bounces. X# should be a value between 0 and 1, to represent the progression from start to finish.




Kezzla
10
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 23rd Nov 2012 05:14
ok, here's a very simple yet useful function that I searched for and couldn't find here.

It takes a float value, rounds it down to the desired decimal place and then returns it as a string.

I had a use for displaying floats and found there were too many decimal places displayed.

I was really surprised this function wasn't included with AppGameKit native.



Hodgey
9
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 23rd Nov 2012 06:06
Quote: "I was really surprised this function wasn't included with AppGameKit native."

One can do this:

str(2.597893, 2)

But this rounds up.

Kezzla
10
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 23rd Nov 2012 06:24
ahhh, sweet, thankyou. I've only just started playing with AppGameKit and a lot of the commands functions are still unknown. I thought It had to be there in some place obvious. cheers

Toctoc
6
Years of Service
User Offline
Joined: 10th Jan 2013
Location:
Posted: 13th Jan 2013 17:27
Hello everyone.
Firstly, I apologize for my English ... I use google translator to communicate.
I hope to contribute by offering a lot of features.
These functions must be placed together.
She used to have a tile-based rendering.


An example of usage:

This example uses the joystick to move the view.
GB_Tiles.png file is found at http://puu.sh/Lgq4
collisions will be easy to implement later.
Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 13th Jan 2013 22:42
Nice toctoc
Add it to the codebase
You find where you put it to the code base at your profiles main page.
And select agk snippet.

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Toctoc
6
Years of Service
User Offline
Joined: 10th Jan 2013
Location:
Posted: 13th Jan 2013 23:45
Thank you
I added features in the codebase.
AgentSam
7
Years of Service
User Offline
Joined: 14th Mar 2012
Location: Virtual Space
Posted: 18th Jan 2013 06:02
Toctoc,

Could you also post that tilemap as a message attachment, so that we don't suddenly lose it. Because, I don't think the image retention on puu.sh can be relied on. Those types of services usually purge images a few months after they're posted, and that would mean people can no longer grab the image resource to try out your example.

Also, did you create that tilemap yourself, or where did it come from?

Cheers,
AgentSam
AgentSam
7
Years of Service
User Offline
Joined: 14th Mar 2012
Location: Virtual Space
Posted: 18th Jan 2013 06:06
Toctoc,

Just to make it easy to find your codebase entry, I'm adding it's link here:
tile-based rendering: set of functions for tile-based rendering
(The above link will only work if you are logged in.)

Cheers,
AgentSam
Cliff Mellangard 3DEGS
Developer
13
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 18th Jan 2013 13:30 Edited at: 18th Jan 2013 13:31
A shrink image function at runtime using memblocks i made.
I dont remember if iam supposed to add something to the function name or its removed ?

http://forum.thegamecreators.com/?m=forum_view&t=203006&b=41



Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Velector
6
Years of Service
User Offline
Joined: 8th Jan 2013
Location:
Posted: 25th Jan 2013 16:13
I am not sure if this has already been posted, and apologise if it has been. Last night, I had the need to move a sprite along a cubic bézier curve. A friend passed me this link:
http://www.moshplant.com/direct-or/bezier/math.html

After taking some time to break down the formula to learn how it works, we tested it in Maya using Python against Maya's bézier tool with great success, and I ported it over to AppGameKit, split into two functions. CubicBezierCurveX#() and CubicBezierCurveY#().

(x0#, y0#) and (x3#, y3#) are your start and end points.

Usage: Store these anywhere, but make sure they are within scope of the functions.



The loop to drive t#, and move a dummy sprite along the curve



The functions:


Below is a screenshot of it in action in Maya. The lines are Maya's built in bézier tool, and the spheres are the formula used as a Python script.
Ancient Lady
Valued Member
15
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 25th Jan 2013 17:57
This is very cool. I think something similar has been posted, but your code snippets make it very easy to use.

I think I'll make a similar Tier 2 function set (I can see using this in my WIP game) and I'll post the functions/class when it is done.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Markus
Valued Member
15
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 26th Jan 2013 14:33 Edited at: 28th Jan 2013 21:52
for my Nine Men's Morris game i needed a snap function and to get the pos.
from board some little help functions.

Codebase:
http://www.thegamecreators.com/?m=codebase_view_shot&i=fb9ee75765f78b81c63a42ad10f63cd8
BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 27th Jan 2013 17:02
@Mobiius: I'm using your text wrap functions as a basis for some of my code (thanks ). We can make your Split function much shorter, where you simply want to split using a space (or any other single character):



Naphier
8
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 30th Jan 2013 07:52 Edited at: 30th Jan 2013 07:53
Here's some functions that allow greater control over sound bite looping. It allows you to set the number of loops, an offset between the loops, volume, and decay rate so that you can fade in/out.
It also comes with some handy functions for reading data out of a wav file.

Cheers!

http://www.thegamecreators.com/?m=codebase_view&i=57c786ca30f107537f78c8503b88a333

Attachments

Login to view attachments
Markus
Valued Member
15
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 30th Jan 2013 10:50
Limit a Value
x#=LimitFloat(x#,10.0,90.0)

Daniel TGC
Retired Moderator
12
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 1st Feb 2013 12:00
Thanks for your recent submissions, once Teach Yourself App Game Kit has been written and published I'll revisit this project and get it updated into a single archive.
bstebbs
6
Years of Service
User Offline
Joined: 10th Jan 2013
Location:
Posted: 2nd Feb 2013 05:21
I've been using this software now for 2 months. I'm playing around trying to understand the physics part of it. I'm interesting in making some platform car games but am getting frustrated trying to figure out the right commands to use to get the car to move fast like most online games do.

I created a body of a car and wheels and created weld points using the CreateRevoluteJoint command. That's working now but for the life of me I've tried so many different commands trying to apply force to the car to get it to move and move quickly but nothing seems to work well. When I increase the speed, the car lifts off the ground. And, I've messed with the Gravity command too (SetPhysicsGravity) but can't seem to get anything to work well. Commands I've tried are:

SetSpritePhysicsAngularVelocity
SetSpritePhysicsImpulse
SetSpritePhysicsForce
SetJointMotorOn
CreatePhysicsForce

I can get a car to move slowly across the screen with wheels spinning much faster than the car is moving (which of course makes NO sense) but I can't figure out the right combination to make this work.

I have also used the SetSpritePhysicsMass command to make the car heavier and I've used the SetSpritePhysicsFriction to provide as much friction as I can on the tires and the road. Nothing seems to work well.

Any suggestions? Has anyone done this successfully?
Markus
Valued Member
15
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 2nd Feb 2013 16:45 Edited at: 2nd Feb 2013 16:46
@bstebbs
did you use SetPhysicsDebugOn()
screenshot?
baxslash
Valued Member
Bronze Codemaster
12
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd Feb 2013 08:49
You shouldn't need to mess around with the mass of the sprites, I find it often leads to unexpected results. Gravity should need to be adjusted either. If your sprites seem too heavy, sluggish or too light try adjusting the physics scale using setPhysicsScale instead. This is far more likely to solve these sort of problems.

I would add the two wheels using revolute joints and use two joint motors (one for each revolute joint). Keep the power to these motors equal and don't apply any more forces. There is an example in the physics examples folder but I wouldn't personally make a car that way.

If you have any more problems post the code you are using in a new thread. This thread is for the UCF project. Please start your own threads for your own problems unless they are clearly related to the original post.

I will look out for your thread in case you have any further problems


this.mess = abs(sin(times#))
TrezSoft
AGK Tool Maker
6
Years of Service
User Offline
Joined: 8th Nov 2012
Location: UK
Posted: 5th Feb 2013 23:42
Tween Library for AppGameKit T1.

Posted on Main AppGameKit Forum.

http://forum.thegamecreators.com/?m=forum_view&t=203383&b=41

Just see Velector's post above , this is the next task to include differnt path types within the tween.
Talairina
13
Years of Service
User Offline
Joined: 9th Jan 2006
Location: United Kingdom
Posted: 7th Feb 2013 21:17 Edited at: 8th Feb 2013 12:36
Wow forgot all about this project. Glad to see a couple of my own function's made the grade to be included. Really impressed with some of the functions!
Marl
7
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 15th Feb 2013 18:56
@Markus

I have use similar, if slightly smaller version of the same code

and the equivalent for integer.

Mine are called ClampInt() and ClampFloat(), not that that makes any difference.
Daniel TGC
Retired Moderator
12
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 18th Feb 2013 16:07 Edited at: 18th Feb 2013 16:24
Here's an update for my Accelerometer control functions using the newer universal command set. These functions allow the user to calibrate, then draw output from the X and Y sensors.

Because 0 to 1 is basically a 90 degree turn, these commands allow you to specify a fraction of that, this allows you to draw a full -1 or 1 value directly from the command even if the turn is just a few degrees. For example 0.25 set sensitivity would require the user only to tip their device around 22.5 degrees to get the full 1.0 output and -22.5 degrees to get the full -1 output. This keeps the player screen in full view at all time while generating the sensitivity required.

Furthermore these command add a deadzone, in the example program I set 0.05 which is about 4.5 degrees, this should compensate for any hand shaking or a moving environment such as a train.

Finally it amplifies the output, after all adding 1 or removing 1 pixel at a time to a sprite isn't that fast, by setting this to 5 it multiplies to whole range of motion smoothly. 1 and -1 become 5 and -5, while 0.1 to -0.1 become 0.5 and -0.5 respectively.

Function SetSensor( mode )

Select mode

Case 1

Repeat
Print( "Tap screen to set sensor.")
Sensor.fCentre = GetDirectionY()
Sync()
Until GetPointerPressed() = 1
Sensor.iSet = 0

EndCase

EndSelect
EndFunction

Function SensorY( s#, dz#, amp# )

dY# = GetDirectionY()

If dY# > Sensor.fCentre + s# then dY# = Sensor.fCentre + s#
If dY# < Sensor.fCentre - s# then dY# = Sensor.fCentre - s#
If dY# > Sensor.fCentre - dz# And dY# < Sensor.fCentre + dz# then dY# = Sensor.fCentre

s# = 1 / s#

dY# = dY# - Sensor.fCentre
dY# = dY# * s#

dY# = dY# * amp#

EndFunction dY#

Function SensorX( s#, dz#, amp# )

dX# = GetDirectionX()

If dX# > 0 - dz# And dX# < dz# then dX# = 0

s# = 1 / s#
dX# = dX# * s#

dX# = dX# * amp#

EndFunction dX#


Example program follows.



SetSensor mode (set 1 to activate)
SensorX s# (sensitivity), dz# (deadzone), amp# (amplify output)
SensorY s# (sensitivity), dz# (deadzone), amp# (amplify output)

baxslash
Valued Member
Bronze Codemaster
12
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 18th Feb 2013 23:23
I used that command set in the Cadbury's / Google Campus hackathon project. It was very easy to implement Dan, thanks for the update


this.mess = abs(sin(times#))
Ched80
8
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 5th Apr 2013 20:52
Not sure if this has been added, but I made a wordwrap function:



Hope it's useful for someone.

Naphier
8
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 6th Apr 2013 00:52
@ Ched80
Thanks! This will be helpful to me, but unfortunately it looks like there are some bugs to work out. If I set the width to less than 80 after a few lines of correct wrapping, the following lines only have one word on them. Seems to work fine for strings that only wrap a couple of times.
Cheers!

Ched80
8
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 6th Apr 2013 09:54
@Naphier, that's strange, I use it with a width of 75.0 in my game and it works for me.
Could you send me the string you are using, the settings for the text object and what you see on screen?

Naphier
8
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 6th Apr 2013 19:00
Here you go, Ched80.
I've not had a chance to debug it yet myself, so maybe you'll get to it before me!

The code is simple, the text string is sort of long.



I'm attaching screen shots and my project files.
I've tried in 1089 only and with a couple different resolutions.

Good luck and thanks for working on this, I will find it a useful addition to my tools.

Attachments

Login to view attachments
Ched80
8
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 6th Apr 2013 19:21
Cheers,

This should fix it:



Naphier
8
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 7th Apr 2013 05:29
@Ched80 works great!

Naphier
8
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 16th Apr 2013 06:36
I took Ched's WordWrap function and added on a couple more functions that will allow you to type out text lines from a file onto the screen. Useful for intro stories or old RPG dialogue.

Code base can be found here
http://www.thegamecreators.com/?m=codebase_view&i=8328d2fb727e17582a1fc022bba6dced

I included Ched80's code for completeness.

Phaelax
DBPro Master
16
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th Apr 2013 03:30
Don't know if anyone has posted these yet, but here's a set of vector functions I did awhile back.
http://forum.thegamecreators.com/?m=forum_view&t=192569&b=6&p=0

"You're all wrong. You're all idiots." ~Fluffy Rabbit
Paronamixxe
AGK Bronze Backer
7
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 12th Aug 2013 00:25 Edited at: 12th Aug 2013 00:29
I have a really simple function if you want, commented the **** out of it too... IDIOT PROOF! thats how we like it
Anyhow, it prints a string with a \"typewriter\" effect:


here is the normal version:


Daniel TGC
Retired Moderator
12
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 12th Aug 2013 02:30 Edited at: 12th Aug 2013 02:31
Hi Paronamixxe, I've taken your idea and improved it, frankly because you made me wonder how I'd go about producing such a typing effect in real time rather than within closed loops.

This is a heavily modified version of Paronamixxe's typewriter effect. Mine differs in that it's real time and loop-less. So users can perform other program operations while the text is appearing. I've also thrown in sound audio sounds so you can hear typing. I've replaced print with a text object and organised the data into a global and type.

This version is timer based not loop based. I've thrown in a spinning sprite just to demonstrate you can do anything else while it types out.

I have also attached the project for you to download, the sounds were recorded by myself using my own keyboard so they are royalty free to use.

Attachments

Login to view attachments
Paronamixxe
AGK Bronze Backer
7
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 12th Aug 2013 10:14
Awesome! Probably a VAST improvement on my simple version ^-^ I was using it for a simple text based game So I didnt have to worry about sprites and other things going on

BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Jul 2015 00:46
I have moved this to Newcomers corner and stickied it again, as we have quite a few new members via Humble Bundle.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Cybermind
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 28th Jul 2015 15:21
Here is an image scale up function that does not smooth out pixels the way scale sprite does.



The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Scraggle
Moderator
15
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 9th Aug 2015 20:42
I recently found the need to scale some text to fit a certain area. However, because I am using multiple languages I have no idea how large the text string will be.
I could use SetTextMaxWidth() but the downside to that is that any text that is too large will split onto the line below.
Instead I could use SetTextScissor() but that has the problem of cropping any text that doesn't fit.

Neither solution is desirable under every circumstance. It may be a better solution to set the size of the text to fit but if you don't know how big the text is then what size do you make it?

So, here is the answer: A function that will scale the text to fit a desired size.



And here it is in a full project that you can copy/paste and run:


Parameters
txtObj - A previously created text object
width - The screen width to fit the text into
AdjustIfFits - A boolean. If TRUE(1) then the text will be scaled up or down to adjust it to the 'width' parameter. If False(0) then the text will not be scaled if it already fits within the required width but is smaller.


Because the function contains a loop I wouldn't recommend using it in real-time but it is perfect for setting up a HUD before a game.

Here is an example from my current project which demonstrates why I needed it.


AGK V2 user - Tier 1 (mostly)
BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 9th Aug 2015 20:51 Edited at: 9th Aug 2015 20:52
This is how I do the same, but please tell me if there is a flaw in my logic. So far it has worked for me. In my case the text can be a smaller width, but never longer...



Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Scraggle
Moderator
15
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 9th Aug 2015 21:00 Edited at: 9th Aug 2015 21:08
Well that's embarrassing!

I was going to ask if anyone knew of an algorithm to work it out but decided I could do it myself.
Your method is far quicker and more elegant.

In an attempt to save face I have made a slight improvement:



Thanks BatVink!!!

AGK V2 user - Tier 1 (mostly)
BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 9th Aug 2015 21:09
Quote: "Well that's embarrassing!"


Not at all! Take a look at some of my trigonometry posts, I can write 100 lines where I only need 1.

I think it's called overthinking the problem, and we are all guilty of it...regularly!

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Clonkex
Forum Vice President
9
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 10th Aug 2015 10:00
Quote: "I think it's called overthinking the problem, and we are all guilty of it...regularly!"


Too true, too true...

Jack
14
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 11th Oct 2015 23:50
Hello fellas!

The following code can create a simple node network and use a smart pathfinding function to find the shortest path to the target. This is an attempt to create a node based A* pathfinding function. But I couldn`t understand the pseudocode given by
the tutorials on the web, and the forum and codebase pathfinding functions only support 2d pathfinding functions, which do work perfectly but do not cover my special need for a simple node creation/pathfinding snippet
I know there is no G value in it, I did not feel to need this one, but if you want to add something like distance between nodes, each node should have a position and parallel to the element[] you have to add another array in the type to track the distance.
Simply, each Link between nodes should get a distance value, anyway, enjoy:




[/url]
GunnerJnr
AGK Developer
3
Years of Service
User Offline
Joined: 30th Nov 2015
Location: Bridgwater, UK
Posted: 21st Dec 2015 13:15
Wish I had seen this thread before now, especially the DebugLog functions, I kinda ended up writing my own make shift one for that using some of AGK's nifty functions to help, perhaps mine isn't the most efficient or best way of doing it, but it works for my purposes. You can view it HERE on the thread I just shared it at. Also great work to everybody else there are some great functions in here DegToRad and ViceVersa are definitely ones needed and ^^ I see above someone commented about writing a long winded way to do something and someone else posted the same with just a few lines, I am a long winded person myself so I feel your pain, I constantly overthink things and make life way harder than it should be. But its all part of the learning process

Cheers
Multicoder
AGK Developer
4
Years of Service
User Offline
Joined: 25th Oct 2014
Location: Germany
Posted: 6th Jan 2016 14:12 Edited at: 6th Jan 2016 14:17
I didn't read all posts, so it is possible, that something similar already exists.
(Rotate sprite to face pointer)

Yes, I am aware that I sound like a caveman to native english speakers

Login to post a reply

Server time is: 2019-06-26 10:40:03
Your offset time is: 2019-06-26 10:40:03