Adam's Lair Forum

game development and casual madness
It is currently 2017/04/25, 08:37

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 41 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
PostPosted: 2016/01/22, 12:20 
Member
Member

Joined: 2015/11/04, 20:02
Posts: 69
Location: Canada
Role: Hobbyist
Thanks for the kind words :)

SirePi wrote:
Do you plan to release some sort of walkthrough of how you did some of the cool things you described?

Potentially. I'd love to do complete technical walk-through's at some point as my way of giving back to the community. The issue for me is finding time. When I'm not working on the game I'm holding down a day job, or spending time with the lady. We'll see what happens!

SirePi wrote:
Finally, is that ok if I steal some ideas from you to apply to my own game? For example, I never thought about using Markov chains to generate names.. it sounds much better than the hardcoded name bank I'm using now.

Keep up the wonderful work :mrgreen:

Absolutely! Feel free, I didn't come up with the majority of this stuff, I just try to apply it as best I can. I'd love to see what others do. We can all write better games if we're bouncing ideas and implementations off of one another :D


Top
 Profile  
 
PostPosted: 2016/01/26, 06:31 
Member
Member

Joined: 2015/11/04, 20:02
Posts: 69
Location: Canada
Role: Hobbyist
Doop doop dee doop! Incoming update before I fall asleep at my desk (apologies if I ramble or make mistakes)!

I'm about 80% finished the menu system. There were a few hair-pulling moments, but after roughly 18 hours solid of working over a few days (I use a neat app to keep track of my hours working on the project :)) the infrastructure is in a state I am happy with. Additionally, the work done to get this working the way I wanted to will be really important for the rest of the project.

Here's a little gif of a couple lonely menu widgets, volunteering to test out a new system for me!
Image

These are basic buttons with "Game Actions" attached to them to achieve the coloring and resizing effects. Game actions are more or less a variation on the Command pattern. There are standard actions as well as multi-frame actions. In order for a class to use game actions all it must do is inherit an interface and then populate that interface with a very small amount of boilerplate.

They are designed to be used across a wide variety of cases in the game, from UI interaction/animation as pictured to game logic and ship controls, and everything in between.

Game actions run concurrently on each object, however they are authoritative over one another in that they can legally pause or resume other game actions not flagged critical and attached to the same object.

Each game action is run once and discarded, or in the case of multi-frame game actions is allotted an amount of run-time in milliseconds when it is created, and it runs for that duration or until it voluntarily raises its ExecutionComplete flag (this flag is automatically raised when the allotted time runs out). Technically as it stands you could create a game action with an enormous run time and it will just continue to run effectively forever, however I designed the allotted-time system to help ensure running game actions don't accumulate, and also to reinforce the idea that they are supposed to be temporary pieces of code, they are supposed to carry out a task and then die.

When a game action dies, its cleanup function is called, where it has the opportunity to clean up any operation it was executing, and/or launch a new game action. So chaining is possible, in fact you could build a state machine/automata or some other construct using game actions quite easily.

Game actions are designed to mesh well with Events. Their simple interface makes it very easy to create one off lambda delegates to launch game actions with.

In order to complete the menu system I need to flesh out the rest of the forms types, and then later on I'll be doing a graphics pass over them. Menus are currently butt-ugly but I have some really cool plans for their aesthetics that you guys should stay tuned for :)

Anyway, that's all for now, sleeeeeeeeep :ninja:


Top
 Profile  
 
PostPosted: 2016/01/28, 22:02 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 1948
Location: Germany
Role: Professional
Nice work ^^ Don't have much to say about the internals you presented, but rest assured that you've made me a little curious on what will come out of it.

Also, this:
Quote:
Gfycat Video - Click to Play. [Source]

looks really neat. Thumbs up.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2016/02/16, 20:47 
Member
Member

Joined: 2015/11/04, 20:02
Posts: 69
Location: Canada
Role: Hobbyist
Ugh it's been so hard to find time to get everything that needs doing done lately, and consequently there has been a severe lack of updates here. I'll do my best to fix that moving forward! :)

I propose a motion to reconfigure the earths orbit to allow for 36 hour days. The floor is open for comment.


Top
 Profile  
 
PostPosted: 2016/02/16, 21:20 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 1948
Location: Germany
Role: Professional
ARC wrote:
Ugh it's been so hard to find time to get everything that needs doing done lately, and consequently there has been a severe lack of updates here. I'll do my best to fix that moving forward! :)

I think most of us know this situation and I'm sure we can all relate when it takes a bit until you manage to get a new update out there. Don't worry about that too much ^^

(Edit: Though if there was an update I certainly wouldn't mind :mrgreen: )

ARC wrote:
I propose a motion to reconfigure the earths orbit to allow for 36 hour days. The floor is open for comment.

Approved. Let's do it.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2016/02/16, 21:49 
Forum Addict
Forum Addict
User avatar

Joined: 2013/09/19, 14:31
Posts: 821
Location: Italy
Role: Hobbyist
ARC wrote:
Ugh it's been so hard to find time to get everything that needs doing done lately, and consequently there has been a severe lack of updates here. I'll do my best to fix that moving forward! :)

I know the feeling.. being there myself right now :rly:
ARC wrote:
I propose a motion to reconfigure the earths orbit to allow for 36 hour days. The floor is open for comment.

I agree as well, as long as the work day remains of 8 hours and body still requires 8 hours only of sleep ^^

_________________
Come on Duality's Discord channel. It's entertaining and productive! :mrgreen:


Top
 Profile  
 
PostPosted: 2016/02/16, 22:07 
Forum Adept
Forum Adept

Joined: 2015/07/08, 16:41
Posts: 414
Role: Gamer
ARC wrote:
I propose a motion to reconfigure the earths orbit to allow for 36 hour days. The floor is open for comment.
Now that I think about it, changing the day length by even one hour would be enough to bring total chaos to every single piece of technology that uses dates and time... it would screw up pretty much the entire world.

Also, isn't it the rotational period, not the orbital period? It would be pretty horrific if we completed an orbit around the Sun every 36 hours. The number of New Year parties alone would drive me crazy.

Good luck getting the game along - it's nice to keep track of your progress.


Top
 Profile  
 
PostPosted: 2016/02/16, 22:39 
Forum Adept
Forum Adept

Joined: 2014/12/13, 00:11
Posts: 397
Location: Brazil
Role: Gamer
hsnabn wrote:
Also, isn't it the rotational period, not the orbital period? It would be pretty horrific if we completed an orbit around the Sun every 36 hours. The number of New Year parties alone would drive me crazy.

I think orbital period is the time a planet or body takes to complete an orbit around itself.

ARC wrote:
I propose a motion to reconfigure the earths orbit to allow for 36 hour days. The floor is open for comment.

I don't work yet, but let's do it!

_________________
I only know the basics of C#. I have no advanced knowledge.


Top
 Profile  
 
PostPosted: 2016/09/23, 05:07 
Member
Member

Joined: 2015/11/04, 20:02
Posts: 69
Location: Canada
Role: Hobbyist
Felt like sharing a little so that you guys at least get something out of this project. Here's the complete and un-edited (and un-commented) frag shader for the stars. There's probably some weird stuff in here because it was born of rapid iterations, and it's hard to read code, but if you can figure out how to plug it in to Duality then you should be able to get some nice stars on the screen.

Note: I did not author the noise functions themselves. Pretty much everything else though.

Code:
#define PI 3.1415926535897932384626433832795
 
uniform sampler2D sceneTex;
uniform float u_time;
uniform float u_radius;
uniform vec3 u_color;
uniform vec2 u_center;
uniform vec2 u_k;

float rand(vec2 co){
    return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}

float nsin(float co){
   return (1.0 + sin(co)) / 2.0;
}

float snoise(vec3 uv, float res)   // by trisomie21
{
   const vec3 s = vec3(1e0, 1e2, 1e4);
   
   uv *= res;
   
   vec3 uv0 = floor(mod(uv, res))*s;
   vec3 uv1 = floor(mod(uv+vec3(1.), res))*s;
   
   vec3 f = fract(uv); f = f*f*(3.0-2.0*f);
   
   vec4 v = vec4(uv0.x+uv0.y+uv0.z, uv1.x+uv0.y+uv0.z,
                 uv0.x+uv1.y+uv0.z, uv1.x+uv1.y+uv0.z);
   
   vec4 r = fract(sin(v*1e-3)*1e5);
   float r0 = mix(mix(r.x, r.y, f.x), mix(r.z, r.w, f.x), f.y);
   
   r = fract(sin((v + uv1.z - uv0.z)*1e-3)*1e5);
   float r1 = mix(mix(r.x, r.y, f.x), mix(r.z, r.w, f.x), f.y);
   
   return mix(r0, r1, f.z)*2.-1.;
}

vec4 mod289(vec4 x)
{
    return x - floor(x * (1.0 / 289.0)) * 289.0;
}
 
vec4 permute(vec4 x)
{
    return mod289(((x*34.0)+1.0)*x);
}
 
vec4 taylorInvSqrt(vec4 r)
{
    return 1.79284291400159 - 0.85373472095314 * r;
}
 
vec2 fade(vec2 t) {
    return t*t*t*(t*(t*6.0-15.0)+10.0);
}

// Classic Perlin noise
float cnoise(vec2 P)
{
    vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);
    vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);
    Pi = mod289(Pi); // To avoid truncation effects in permutation
    vec4 ix = Pi.xzxz;
    vec4 iy = Pi.yyww;
    vec4 fx = Pf.xzxz;
    vec4 fy = Pf.yyww;
     
    vec4 i = permute(permute(ix) + iy);
     
    vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0 ;
    vec4 gy = abs(gx) - 0.5 ;
    vec4 tx = floor(gx + 0.5);
    gx = gx - tx;
     
    vec2 g00 = vec2(gx.x,gy.x);
    vec2 g10 = vec2(gx.y,gy.y);
    vec2 g01 = vec2(gx.z,gy.z);
    vec2 g11 = vec2(gx.w,gy.w);
     
    vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));
    g00 *= norm.x; 
    g01 *= norm.y; 
    g10 *= norm.z; 
    g11 *= norm.w; 
     
    float n00 = dot(g00, vec2(fx.x, fy.x));
    float n10 = dot(g10, vec2(fx.y, fy.y));
    float n01 = dot(g01, vec2(fx.z, fy.z));
    float n11 = dot(g11, vec2(fx.w, fy.w));
     
    vec2 fade_xy = fade(Pf.xy);
    vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);
    float n_xy = mix(n_x.x, n_x.y, fade_xy.y);
    return 2.3 * n_xy;
}

// Classic Perlin noise, periodic variant
float pnoise(vec2 P, vec2 rep)
{
    vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);
    vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);
    Pi = mod(Pi, rep.xyxy); // To create noise with explicit period
    Pi = mod289(Pi);        // To avoid truncation effects in permutation
    vec4 ix = Pi.xzxz;
    vec4 iy = Pi.yyww;
    vec4 fx = Pf.xzxz;
    vec4 fy = Pf.yyww;
     
    vec4 i = permute(permute(ix) + iy);
     
    vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0 ;
    vec4 gy = abs(gx) - 0.5 ;
    vec4 tx = floor(gx + 0.5);
    gx = gx - tx;
     
    vec2 g00 = vec2(gx.x,gy.x);
    vec2 g10 = vec2(gx.y,gy.y);
    vec2 g01 = vec2(gx.z,gy.z);
    vec2 g11 = vec2(gx.w,gy.w);
     
    vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));
    g00 *= norm.x; 
    g01 *= norm.y; 
    g10 *= norm.z; 
    g11 *= norm.w; 
     
    float n00 = dot(g00, vec2(fx.x, fy.x));
    float n10 = dot(g10, vec2(fx.y, fy.y));
    float n01 = dot(g01, vec2(fx.z, fy.z));
    float n11 = dot(g11, vec2(fx.w, fy.w));
     
    vec2 fade_xy = fade(Pf.xy);
    vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);
    float n_xy = mix(n_x.x, n_x.y, fade_xy.y);
    return 2.3 * n_xy;
}

float fbm(vec2 P, int octaves, float lacunarity, float gain)
{
    float sum = 0.0;
    float amp = 1.0;
    vec2 pp = P;
     
    int i;
     
    for(i = 0; i < octaves; i+=1)
    {
        amp *= gain;
        sum += amp * cnoise(pp);
        pp *= lacunarity;
    }
    return sum;
 
}

float pattern_t( in vec2 p, out vec2 q, out vec2 r , in float time)
{
    float l = 4.3;
    float g = 0.4;
    int oc = 2;
     
    q.x = fbm( p + vec2(time,-time),oc,l,g);
    q.y = fbm( p + vec2(-5.2*time,1.3*time) ,oc,l,g);
    r.x = fbm( p + 4.0*q + vec2(1.7,9.2),oc,l,g );
    r.y = fbm( p + 4.0*q + vec2(8.3,2.8) ,oc,l,g);
     
    return fbm( p + 4.0*r ,oc,l,g);
}

void main() {
   float v = 0.0;
   vec2 uv = gl_TexCoord[0].xy;
   vec2 texCoord = vec2(uv);
   vec4 color = texture2D(sceneTex, texCoord);
   vec4 result = vec4(color);   
   result.xyz = u_color;   
   
   vec2 p = -2.0 + 4.0 * texCoord.xy;
   float r = distance(vec2(0.5, 0.5), uv);
   r = sqrt(dot(p, p));

   if(r < 1.0)
   {
      float f = ((1.0 - sqrt(1.0 - r)) / r);
      texCoord.x = p.x * f;
      texCoord.y = p.y * f;
   }

   texCoord *= u_k - u_k / 2.0;   

   if(color.a > 0.5)
   {
      vec2 qq;
      vec2 r;
      float ca0 = pattern_t(texCoord * 0.5, qq, r, u_time / 32.0) / 2.0;
      result.xyz += ca0;
   }
   else
   {
      vec2 qq;
      vec2 r;
      float ca0 = pattern_t(texCoord * 0.1, qq, r, u_time / 128.0) * 1.0;
      float ca1 = pattern_t(texCoord * 0.5, qq, r, u_time / 64.0) * 1.0;
      float d = clamp(0.5 - distance(vec2(0.5, 0.5), uv), 0.0, 1.0);
      result.a = pow(0.1 * (smoothstep(0.0, 0.4, (ca0 * pow(d, 5) * 1e3))), 1.0) + pow(d, 1.3);
      
      texCoord.x = p.x;
      texCoord.y = p.y;
      result.a += pow(0.1 * (smoothstep(0.1, 0.4, (ca1 * pow(d, 5) * 1e3))), 1.0);
   }
   gl_FragColor = result;
}


You're free to use this code, I'm actually working on a better looking, faster performing version (I can't give away all of my secret sauce :) ). But the core concepts remain the same.

If you know nothing about shaders, the long and short of it is that this code is run for every pixel on the screen occupied by a star's sprite. Through a whole bunch of math it turns a totally blank sprite into a pretty, animated star. It might look like a lot of code to be running per-pixel, but it's what graphics cards are made for. Your jaw would drop at the amount of shader code used in modern AAA games. These stars when occupying the entire screen run at a ridiculously high FPS on my R9 390X. Even so, you could optimize this code a lot.

Edit: You're also encouraged to play with the code! Poke and prod, see what each thing does. Duality supports hot-loading the shaders while they are running in the editor, so it's super easy to see what effect you're having instantly. Here's a cool effect I stumbled on:

I really like the red ones


Top
 Profile  
 
PostPosted: 2016/09/23, 10:40 
Forum Adept
Forum Adept

Joined: 2015/07/08, 16:41
Posts: 414
Role: Gamer
Ooh, nice! I'm going to start learning OpenGL and in turn shaders some time, so it'll be useful. Thanks!

Side note: The shader seems to be 80% noise functions. The main function is actually quite digestible. Nice.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 41 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group