Commits

Alberto Fernández committed 6a83e7a

Jumping impl

Comments (0)

Files changed (3)

                 self.dialog = DialogBackground:new()
                 self:add(self.dialog)
         end
-}
+}
+
+JumpingActor = {
+        triggerKey = "up",
+        
+        jumping = false,
+        
+        gravity = 350,
+        
+        height = 150,
+        
+        length = 150,
+
+        onUpdate = function(self, actor)
+                if(jumping == false) then
+                        self.x = actor.x
+                        self.y = actor.y
+                end
+                
+                if(the.keys:pressed(triggerKey) and jumping == false) then
+                        jumping = true
+                        
+                        actor.x = self:calculateJumpX()
+                        actor.y = self:calculateJumpY()
+                end
+        end,
+        
+        calculateJumpX = function(self)
+                -- calcular hasta donde llega el salto en base a la aceleración
+                if(the.keys:pressed("right")) then
+                        self.x = self.acceleration+self.x
+                end
+                
+                if(the.keys:pressed("left")) then
+                        self.x = self.x-self.acceleration
+                end
+                
+                return self.x
+        end,
+        
+        calculateJumpY = function(self)
+                self.y = acceleration+self.y
+                
+                return self.y
+        end
+}
+
+MovingActor = {
+
+}
+
+ShotingActor = {
+        -- definir que tipo de disparo se hará
+        -- angulo en el que realizar el disparo
+        -- 
+}
+

menu/assets/shaders/button.glsl

+extern vec3 light_vec;
+extern Image diffuse;
+
+vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords)
+{
+   vec3 light_direction = light_vec - vec3(pixel_coords, 0);
+   float distance = length(light_direction);
+   light_direction = normalize(light_direction);
+
+   vec3 normal = Texel(texture, texture_coords).xyz;
+   normal.y = 1 - normal.y;
+   normal = normalize(mix(vec3(-1), vec3(1), normal));
+
+   //float attenuation = 1/(7e-5*pow(distance, 2));
+   float attenuation = 5000/pow(distance, 2);
+   //float attenuation = 1;
+
+   float diffuse_term = clamp(attenuation * dot(normal, light_direction), 0.0, 1.0);
+
+   vec3 dark_color = vec3(0.0, 0.0, 1);
+   //vec3 light_color = vec3(0.6, 0.6, 0.0);
+   vec3 light_color = vec3(0.8, 0.8, 0.0);
+   vec3 ambient = mix(dark_color, light_color, diffuse_term) * 0.20;
+
+   // the shaded cel has a light value of 0.5, the light cel has a light value of 1
+   float cel_diffuse_term = smoothstep(0.49, 0.52, diffuse_term)/2 + 0.5;
+   //float cel_diffuse_term = step(0.5, diffuse_term)/2 + 0.5;
+
+   return vec4((cel_diffuse_term * Texel(diffuse, texture_coords).rgb) + ambient, Texel(texture, texture_coords).a);
+   //return vec4(ambient+Texel(diffuse, texture_coords).rgb/100, Texel(texture, texture_coords).a);
+}
                 width = 223,
                 height = 37,
                 
-                image = 'menu/assets/graphics/button.png'
+                image = 'menu/assets/graphics/button.png',
+                
+                onNew = function(self)
+                        self:setEffect('menu/assets/shaders/button.glsl')
+                end
         },
         
         onMouseEnter = function(self)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.