Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


Madhed

Member Since 13 Jun 2001
Online Last Active Today, 10:34 AM

#5159591 Refactoring if-conditions for player turn code

Posted by Madhed on 10 June 2014 - 02:13 PM


Yep, this does indeed work, thanks a lot, thats a whole lot easier. Except that I somehow got up and down mixed up, at least its easier to fix in your version So the general advice for such monstrous if-statements would be "look for an easier algorithmn", or is there some recommandation in case there is no easier algorithmn scheme?

 

I started by drawing a crude diagram and looking for a mathematical solution. Sometimes it's easier to visualize that way.




#5159573 Refactoring if-conditions for player turn code

Posted by Madhed on 10 June 2014 - 01:31 PM

unsigned int DirectionFromMove(const math::Vector2& vMove)
{
    if(vDir.x < vDir.y) {
        // left or up
        if (vDir.x > -vDir.y){
            return 3;
        }
        else {
            return 1;
        }
    }
    else {
        // right or down
        if (vDir.x > -vDir.y){
            return 2;
        }
        else {
            return 0;
        }
    }
}

I hope this works... gone testing...

EDIT: Seems to work. What this does is separating the space by the function f(x) = x and after that by the function f(x) = -x testing which side of the half-plane the point lies in.




#5159239 whats this? javscript/ga

Posted by Madhed on 09 June 2014 - 06:28 AM

Fir, if you only want to talk you should post to the lounge.

 

I don't know if it is the language barrier playng into this, but your attitude just comes over as rude and condescending. You can't expect other users of this forum spoon feeding you the solutions to problems you encounter while you are programming, when you could have found the answers yourself with half an hour of research.

 

Instead you are expecting dozens of people to invest their own free time to do the work for you while you sit around and wait for the responses to fly in.

 

Take your original post for example: If I hadn't known what this code does I would have immediately seen the string "GoogleAnalyticsObject". Put the exact string into google search and the second result is a detailed explanation of what this code does.




#5159146 whats this? javscript/ga

Posted by Madhed on 08 June 2014 - 03:04 PM

fir, you should probably first learn the basics of javascript before diving into canvas stuff etc. As a seasoned js coder I can assure you that you will have many more WTF moments in the future.

 

Most of the stuff you have asked here will be covered in any javascript tutorial online.

 

* Quirks of the *this* pointer

* event handlers

* regular expressions

 

etc etc.




#5159116 whats this? javscript/ga

Posted by Madhed on 08 June 2014 - 12:46 PM

/Android|webOS|iPhone|iPad|iPod|BlackBerry/i

Is a regular expression. Javascript has a special syntax to create them on the fly.




#5158540 Screenspace Shadow Mapping Help!?

Posted by Madhed on 05 June 2014 - 03:35 PM

Found this siggraph crytek paper from last year. http://www.crytek.com/download/Playing%20with%20Real-Time%20Shadows.pdf

 

They are talking about shadows in general and there is a tiny little section about screen space self shadowing that seems to use this technique.

As a screen space technique it's not a drop-in replacement for regular shadow maps, really just an addon to increase fidelity.

 

I can imagine it working pretty well for range restricted point lights though.

 

Are you using deferred lighting? Then it should be a pretty straight forward to incorporate the tracing into the rendering of the point light polygons.




#5158382 [updated]: Make certain objects arrive in the scene (a lorry)

Posted by Madhed on 05 June 2014 - 07:33 AM

so you have a list of trucks that arrive after a specified amount of minutes plus or minus a random amount of minutes. And you want to take the next truck out of this list when the amount of minutes has passed.

 

Is this correct?




#5157531 Is working in terminal/console really a waste of time?

Posted by Madhed on 02 June 2014 - 07:34 AM

The good thing about coding for the console is that you don't need to include dozens of huge confusing libraries when starting out. You can focus on learning algorithms and data structures.

 

As Promit pointed out, console programs can be quite useful. Especially when you need some custom tools in your production pipeline.




#5157235 Why do graphic intensive game use a lot of energy

Posted by Madhed on 31 May 2014 - 05:24 PM

 


Each transistor on a processor consumes power while it's active -- a certain amount while open, less while closed. There's also energy consumed in switching, but even when not in use they are draining some power.

 

Are you sure about that? I though transistors in a CMOS configuration use negligible energy when in a stable state.

 

 

Correct, most power is dissipated during switching. The negligible current while in a stable state is actually the reason CMOS is used.




#5153633 About entity component system design

Posted by Madhed on 14 May 2014 - 01:17 PM

Wait. You're using Unity right? Unity itself already contains an ECS.

 

Components are subclasses of Unity's MonoBehaviour class.

Entities are instances of Unity's Entity class.

 

Systems don't really exist in Unity because it uses the kind of entity system where components also contain logic.

 

To me it seems kind of "wrong" to implement your own ECS on top of that.




#5149830 Screenshot of your biggest success/ tech demo

Posted by Madhed on 27 April 2014 - 05:14 AM

I did some freelance programming on My Dolphin Show. Nothing next-gen though but a fun little game that's getting good reviews and has a few million installs.

Get it! it's free :D

 

https://play.google.com/store/apps/details?id=com.spilgames.mydolphinshow&hl=de

 

https://itunes.apple.com/de/app/my-dolphin-show/id632016921?mt=8

 

My-Dolphin-Show-MyDolphinShow.jpg




#5149685 Applications vs. Webapps

Posted by Madhed on 26 April 2014 - 12:24 PM

Yep that actually belongs in the con list. Dont know how it ended up there.
As for transpilers. Didn't really think of that. Good point.
Im not against pure JavaScript either. Just thought that might be a negative for people who are used to other languages.


#5149667 Applications vs. Webapps

Posted by Madhed on 26 April 2014 - 10:52 AM

A webapp is just an application that runs in the browser using web technology like html, javascript, xhr, etc.

 

Pros:

- user does not need to install the software

- user does not need to update the software

- cross platform

- sandboxed (browser separates app and os)

- rich design language (css)

 

Cons:

- requires internet access at all times (except if you do advanced stuff like html5 application cache)

- javascript

- can be slower than a native app

- browser differences can make development difficult

- sandboxed (if the app needs access to "unsafe" os functions you're SOL)




#5142643 Using MakeHuman..is it cheating?

Posted by Madhed on 27 March 2014 - 11:38 AM

IMO using such a tool as a starting point to make your own characters is perfectly fine.

Why should you reinvent the wheel?

 

When I'm coding I can use thousands of libraries that other people have written and use those with my own written code to put together a finished product.

Why should artists not do the same?




#5142145 Javascript Memory leak

Posted by Madhed on 25 March 2014 - 05:26 PM

@JohnnyCode:

 

There are two ways to use setInterval.

 

1. Pass function as a reference: setInterval(function() { doSomething(); }, 10);

 

2. Pass an expression as a string: setInterval("doSomething();", 10);






PARTNERS