Project categories


Project site header
Category
Web
Platform
PC
Language
Joomla (CSS/PHP/XHTML)
Type
nCode project
Team members
1
Date
2011
State
Completed

Description

This is actually the site you are currently visiting. It is my programming portfolio, so I can showcase some of my to everyone. I guess this is the most self explanatory project in the whole site. The web site is built on Joomla and presents the following features:

  • Customized and original template.
  • Projects pages, all with the same structure.
  • Image galleries with fullscreen pop-up like window display.
  • Embeded videos, both local and remote.
  • Sample code for some projects.
  • A curious script for simulating flocks in the header of the site. Since this is a site about programming, a small script was specially developed for it.

Images

Video

No video available for this project.

Code sample

This code snippet shows the function responsible of the AI behaviour of the boids. It is a function of the Herd object, that holds also all the movings boids.

flocking.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
 
Herd.prototype.applyRules = function ()
{
    var avg_pos = new Point2d();
    var avg_sep_dir = new Point2d();
    var avg_angle = 0;
    var avg_count = 0;
    var avg_count_sep = 0;
 
    for (var i=0; i<this.boids.length; i++)
    {
        avg_pos.x = 0.0;
        avg_pos.y = 0.0;
        avg_sep_dir.x = 0.0;
        avg_sep_dir.y = 0.0;
        avg_angle = 0;
        avg_count = 0;
        avg_sep_count = 0;
 
        for (var j=0; j<this.boids.length; j++)
        {
            if (this.visible(i,j))
            {
                avg_count++;
                avg_pos.x += this.boids[j].pos.x;
                avg_pos.y += this.boids[j].pos.y;
 
                avg_angle += this.boids[j].dir.angle();
            }
 
            if (this.visible2(i, j))
            {
                avg_sep_dir.x = this.boids[i].pos.x - this.boids[j].pos.x;
                avg_sep_dir.y = this.boids[i].pos.y - this.boids[j].pos.x;
 
                var dst = avg_sep_dir.length();
 
                var steer = avg_sep_dir.angle() - this.boids[i].dir.angle();
                if (steer > Math.PI) steer = steer - 2* Math.PI;
                else if (steer < -Math.PI) steer = 2*Math.PI + steer;    
                steer = steer > 0 ? 1.0 : -1.0;
                steer *= (100.0 - dst/10.0);
                this.boids[i].addSteer(steer * 2.0);
            }
        }
 
        // Cohesion
        if (avg_count > 0)
        {
            avg_pos.x /= avg_count;
            avg_pos.y /= avg_count;
 
            var tmp = new Point2d();
            tmp.x = avg_pos.x - this.boids[i].pos.x;
            tmp.y = avg_pos.y - this.boids[i].pos.y;
            var dst = tmp.length();
            tmp.normalize();
 
            var steer = tmp.angle() - this.boids[i].dir.angle();
            if (steer > Math.PI) steer = steer - 2* Math.PI;
            else if (steer < -Math.PI) steer = 2*Math.PI + steer;
            steer = steer > 0 ? 1.0 : -1.0;
            steer *= dst / 100.0;
            this.boids[i].addSteer(steer * 45.0);
        }
 
        // Alignment
        if (avg_count > 0)
        {
            avg_angle /= avg_count;
 
            var angle = new Point2d();
            angle.x = Math.cos (avg_angle);
            angle.y = Math.sin (avg_angle);
 
            var dst = tmp.length();
            tmp.normalize();
 
            var steer = angle.angle() - this.boids[i].dir.angle();
            if (steer > Math.PI) steer = steer - 2* Math.PI;
            else if (steer < -Math.PI) steer = 2*Math.PI + steer;
            steer = steer > 0 ? 1.0 : -1.0;
            steer *= (2.0 - dst/500.0);
 
            this.boids[i].addSteer(steer * 15.0);
        }
 
        // Target point
        var tmp = new Point2d();
        tmp.x = this.target_pnt.x - this.boids[i].pos.x;
        tmp.y = this.target_pnt.y - this.boids[i].pos.y;
        var dst = tmp.length();
        tmp.normalize();
 
        var steer = tmp.angle() - this.boids[i].dir.angle();
        if (steer > Math.PI) steer = steer - 2* Math.PI;
        else if (steer < -Math.PI) steer = 2*Math.PI + steer;
        steer = steer > 0 ? 1.0 : -1.0;
        steer *= dst / 150.0;
        this.boids[i].addSteer(steer * 15.0);
    }
}

Links

No links available for this project.

NOTE! This site uses cookies and similar technologies.

This site uses cookies and similar technologies. If you not change browser settings, you agree to it. Learn more

I understand