SyntaxBomb - Indie Coders

Languages & Coding => AppGameKit ( AGK ) => Topic started by: Pfaber11 on September 05, 2019, 19:46:53

Title: Alfa value for colours
Post by: Pfaber11 on September 05, 2019, 19:46:53
Could somebody please explain to me what the alfa value does ( red green blue alfa ) what is alfa.
Title: Re: Alfa value for colours
Post by: Steve Elliott on September 05, 2019, 19:51:01
The alpha value is the amount of transparency.  So a value of 255 is solid and 0 would be invisible, something inbetween for a 'ghost-like' look so the background shows through.
Title: Re: Alfa value for colours
Post by: Pfaber11 on September 05, 2019, 21:19:56
Thanks for the reply . Learnt something new today.
Title: Re: Alfa value for colours
Post by: Steve Elliott on September 05, 2019, 21:30:18
Cool.  No problem.
Title: Re: Alfa value for colours
Post by: Pfaber11 on September 05, 2019, 22:38:29
Well I tried it
setobjectcolor(2,0,100,0,255)
and
setobjectcolor(2,0,100,0,1)
and it had no effect. I think I'll just leave it at one for now.
At least now I know what it means .
Title: Re: Alfa value for colours
Post by: Steve Elliott on September 05, 2019, 22:43:56
Use SetSpriteColor.  So this is 3D? I've not used AGK 3D.
Title: Re: Alfa value for colours
Post by: Pfaber11 on September 05, 2019, 23:12:50
steve I've been at the 3d stuff about 6 months now and I love it . I'm no expert but it's great fun . Finished a few games with it so far and am ready to start a new project . Just got to figure out what that project is going to be . Got to grips with textures and am now working on the shaders side of things as in terrain.
Title: Re: Alfa value for colours
Post by: Qube on September 05, 2019, 23:22:05
Quote from: Pfaber11 on September 05, 2019, 22:38:29
Well I tried it
setobjectcolor(2,0,100,0,255)
and
setobjectcolor(2,0,100,0,1)
and it had no effect. I think I'll just leave it at one for now.
At least now I know what it means .

Are you sure that your object has an ID of 2?. Have you tried this example? (https://www.appgamekit.com/documentation/Reference/3D/SetObjectColor.htm)
Title: Re: Alfa value for colours
Post by: Pfaber11 on September 06, 2019, 10:20:21
yes quite sure . I created a sphere with the id of 2 . I'm just playing around at the moment as inbetween games. Here's the code I'm fooling around with.
Project: hm12 shader
// Created: 2019-09-04

// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "hm12 shader" )
SetWindowSize( 1366, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window

// set display properties
SetVirtualResolution( 1366, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts



loadimage(2,"skin12.png")
CreateObjectFromHeightMap(1,"hm12.png",2048,2000,2048,1,0)
setobjectimage(1, 2,1)
CreateObjectSphere(2,30,20,20)
SetObjectColor(2,0,200,0,200)
SetObjectPosition( 1,0,00,100)
setobjectposition(2,1000,400,1000)
  setcamerarange(1,10,5000)
  SetCameraPosition(1,1000,300,1000)
  setcamerarotation(1,0,30,0)
 
 
sync()
do
if GetRawKeystate(65)=1
RotateCameraGlobaly(1,-2)
endif
if GetRawKeystate(68)=1
RotateCameraGlobaly(1,2)
endif
if GetRawKeystate(83)=1
MoveCameraLocalZ(1,-10)
endif
if GetRawKeystate(87)=1
MoveCameraLocalZ(1,10)
endif


    Print( ScreenFPS() )
    Sync()
loop///[code]
Title: Re: Alfa value for colours
Post by: Pfaber11 on September 06, 2019, 10:24:06
When I change the value of the alfa in setobject color it makes no difference . 1 or 101 it's the same. Had an idea for a game using it was thinking of a crystal maze where you can see through the walls .
Title: Re: Alfa value for colours
Post by: TomToad on September 06, 2019, 11:47:09
you need to turn on transparency with SetObjectTransparency(2,1)
Title: Re: Alfa value for colours
Post by: Pfaber11 on September 06, 2019, 11:55:36
Brilliant thanks Tom Toad . Would of never worked that out . Gonna go and have a play with it .
   Just tried it and it appears 1 is invisible 2 is so you can see through it and 3 is solid color. Excellent thank you.
Title: Re: Alfa value for colours
Post by: Rick Nasher on September 08, 2019, 11:41:16
Actually I think no.

With 0 you turn off transparency(default opaque mode) and with the values 1, 2 or 3 you just set transparency on, but with different modes/effects.
The alpha value in the SetObjectColor sets the actual level of transparency. For instance I used below code for creating window glass like effects. But mode 2 can also be useful for that.


// Windows..
wr# as float, wg# as float, wb# as float, wt# as float

wr#=100    // set red, green, blue values..
wg#=100
wb#=100
wt#=100    // and the transparency value

window as integer
window=CreateObjectBox( 340, 200 ,.20 )

SetObjectPosition(window,0,0,0)
SetObjectPosition(  window, -210,100,2220) // you would have to adjust the position and sizes for my world is a bit large.
SetObjectColor (window , wr#, wg#,wb#, wt#) 
SetObjectTransparency(window,1) // turn on transparency in mode 1 = alpha blended.


See also:
Quote
SetObjectTransparency

Description

Sets the transparency mode for this object, 0 is opaque, 1 is alpha blended, 2 is additive blended, 3 is custom blending. Using a transprency value greater than 0 will slow down rendering, it also doesn't write transparent objects to the Z buffer so it might cause some depth ordering problems. There is an alternative form of transparency called Alpha Masking that is useful if you only need fully transparent or fully opaque pixels but no blending in between. See SetObjectAlphaMask for more details.

When using mode 3 (custom) the blend values must be specified with SetObjectBlendModes otherwise the object will not be transparent.


Definition

SetObjectTransparency( objID, mode )


Btw:
You can find the command descriptions online from here:
https://www.appgamekit.com/documentation/search.html

Just enter the command or topic into the search box.

Title: Re: Alfa value for colours
Post by: Pfaber11 on September 08, 2019, 12:17:52
Thanks for that info very useful .
Title: Re: Alfa value for colours
Post by: Rick Nasher on September 08, 2019, 13:19:52
You're welcome.  ;)
Title: Re: Alfa value for colours
Post by: Steve Elliott on September 08, 2019, 13:25:14
Yes I think the majority of AGK Users here seem to just use the 2D features, but there are a few 'special' people that are mad enough to use it for 3D too.   ;D
Title: Re: Alfa value for colours
Post by: Pfaber11 on September 08, 2019, 13:42:57
I personally love the 3D stuff once you get into it it really rocks . Released a few games in 3d now and am about to start work on number 4 . Like the 2d stuff too completed a few games in that as well.
Title: Re: Alfa value for colours
Post by: Steve Elliott on September 08, 2019, 13:48:39
Just kidding, AGK's 3D features are ok I guess.
Title: Re: Alfa value for colours
Post by: Pfaber11 on September 08, 2019, 13:50:43
I see you're running Linux mint 19 on one of your PCs I've also got mint 19 on a separate hard drive just in case windows goes tits up . You never know . Some say windows defender is rubbish but since I've been running it I've had no viruses or adware and it's been a few years now that I've been running windows 10. Although It did crash when installing a major update and I had to do a clean install. Thought I better mention that.
Title: Re: Alfa value for colours
Post by: Steve Elliott on September 08, 2019, 13:55:19
Yes I have a dual boot system for Linux.  On boot I can select Windows 10 or Linux Mint 19, then the appropriate hard drive boots up.  I do use McAfee Total Protection though on Windows 10.  A version of Linux on Raspberry pi too (on which I'm typing this).  The MacBook Pro is in it's case lol.
Title: Re: Alfa value for colours
Post by: Pfaber11 on September 08, 2019, 14:03:54
Nice collection of computers yes I have the dual boot when I plug in the external Hard drive via usb 3 . I did try and run it via a usb 3 flash drive but it was way too slow although did technically work. I also have another windows 10 installation on another hard drive what for I don't know but it may come in handy some time and is quite quick once loaded up.
Title: Re: Alfa value for colours
Post by: Steve Elliott on September 08, 2019, 14:21:49
Thanks, I like to have all bases covered with Windows, Linux and MacOS (but it's only 2 computers).  Plus the cheap little pi4.

Quote
I have the dual boot when I plug in the external Hard drive via usb 3

Cool, mine are internal drives.  But I started with an external USB 3 one.
Title: Re: Alfa value for colours
Post by: Pfaber11 on September 08, 2019, 19:37:53
I'm really glad I took the plunge down the AGK 3d route and would recommend it to anyone . It really isn't any more difficult than the 2d stuff just different and making simple 3d objects is fun . Now the complicated models like people and peoples faces and hands is out of my league . I'm strictly low poly at the moment and maybe for ever . Been doing the 3d stuff since January and glad I did give it a go . For one of my games I combine 2d and 3d and they are both really useful . 3d may seem really daunting at first but once you begin to get your head round it it really is amazing . I thought it would take me 6 months to a year to produce anything but that just isn't the case . Had my first simple 3d game up and running in about 4 weeks  maybe 5 .
AGK2 tier one is an awesome language and should be mainstream. I do remember first downloading AGK2 and it took a while to get into but I am sure I made the right choice . I do think however TGC stating that it is easy to learn and anybody can do it is not strictly accurate . Yes for a computer language it may be on the easier side but computer programming is not for everyone it is a very skillful thing to learn and can get extremely complicated. Even AGK2. I bet that most people who try to do this stuff who have never seen a computer program before fail . I might be wrong but that's what I think. When I first paid my 25 quid for AGK2 I was coming from BBC Basic and stos and at first I felt like a fish out of water , but after six months or so I thought it was great . I still do . Anyway if nobody reads this it's fine .
Title: Re: Alfa value for colours
Post by: Rick Nasher on September 09, 2019, 20:45:52
QuoteI bet that most people who try to do this stuff who have never seen a computer program before fail

True, but that's where forum communities come in.  ;)
Title: Re: Alfa value for colours
Post by: Steve Elliott on September 09, 2019, 21:03:33
Quote
I bet that most people who try to do this stuff who have never seen a computer program before fail

True, but that's where forum communities come in.  ;)

lol very true, this is a great one.  And the guy in charge is not trying to sell you a language either...Or close it down on a regular basis.   ;)
Title: Re: Alfa value for colours
Post by: Pfaber11 on September 09, 2019, 21:08:30
yeah I am glad I found syntaxbomb.