Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411283 Posts in 69325 Topics- by 58380 Members - Latest Member: bob1029

March 29, 2024, 04:04:07 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)The happy programmer room
Pages: 1 ... 166 167 [168] 169 170 ... 279
Print
Author Topic: The happy programmer room  (Read 673151 times)
oahda
Level 10
*****



View Profile
« Reply #3340 on: April 24, 2013, 11:08:16 PM »

I have now got SFML 2.0 compiling in OS X, Linux and cross-compiling for Windows through the latter as well. The Windows executables have proved functional in Wine and by two native testers so far. I am hopeful. This will be an awesome Ludum Dare. Good night!

I did my last LD with SFML, but never again. Last minute issues with people not having the MSVC redist or their card not supporting RenderTextures. It's flash/online for LD for me. I think we got 49th or something in the end due to some cool music we had. But good luck! (Tho I do love SFML and use it for moonman.)
I'm not well-versed enough with any language that allows me to put stuff up online even though it would be preferable. I have made a HTML5 canvas platformer and I know Java, but I don't know the libraries and frameworks well enough by heart to be effective during a 3-day time limit. I may try to brush up on such knowledge before the next one, though. I am making a Java module for my upcoming game's framework after all, so perhaps a web version could be made too. I don't know ActionScript or Unity, unfortunately.
Logged

Dr. Cooldude
Guest
« Reply #3341 on: April 25, 2013, 12:52:19 AM »

Is there any LD participants here on TIGS that's going to livestream their process? I enjoy watching other people program stuff from the ground up.


(Don't be shy, I've already seen how sausages are made. Well, hello there!)
Logged
Quarry
Level 10
*****


View Profile
« Reply #3342 on: April 25, 2013, 01:06:53 AM »

I would but my upload is 100Kb/s
Logged
oahda
Level 10
*****



View Profile
« Reply #3343 on: April 25, 2013, 03:25:25 AM »

I would but my upload is 100Kb/s
Same here. Well, I don't know exactly how many whats a second. But my connection sucks. I know that much.
Logged

eigenbom
Level 10
*****


@eigenbom


View Profile WWW
« Reply #3344 on: April 25, 2013, 04:54:40 AM »

I have now got SFML 2.0 compiling in OS X, Linux and cross-compiling for Windows through the latter as well. The Windows executables have proved functional in Wine and by two native testers so far. I am hopeful. This will be an awesome Ludum Dare. Good night!

I did my last LD with SFML, but never again. Last minute issues with people not having the MSVC redist or their card not supporting RenderTextures. It's flash/online for LD for me. I think we got 49th or something in the end due to some cool music we had. But good luck! (Tho I do love SFML and use it for moonman.)
I'm not well-versed enough with any language that allows me to put stuff up online even though it would be preferable. I have made a HTML5 canvas platformer and I know Java, but I don't know the libraries and frameworks well enough by heart to be effective during a 3-day time limit. I may try to brush up on such knowledge before the next one, though. I am making a Java module for my upcoming game's framework after all, so perhaps a web version could be made too. I don't know ActionScript or Unity, unfortunately.

You'd be surprised how easy it is to get something happening with flash and flixel/flashpunk. I made a game for tig advent with flashpunk in a day or two having no prev flash experience.
Logged

rosholger
Level 1
*



View Profile
« Reply #3345 on: April 25, 2013, 06:33:22 AM »

Oh holy crap! just found java operator overloading plugin!!! the main reason i have been thinking about moving over to scala is now obsolete!  Tears of Joy

uhm, I really wouldn't use that...
you end up with a strange Java that cannot be compiled with anyone not using the plugin and potentially conflicting with future Javas, and there were technical reasons to kill operator overloading:
first, operator overloading makes it easy to spam function calls, which in non-compiled languages are very costly;
second, it encourages to create tons of copies of many small objects because operators should never have side effects on their operands.
Something as simple as

Code:
Vector c = (a + b) * 2.f;

can easily translate to two function calls and two new Vectors being created.
So the Java designer just encouraged (forced?) everyone to write

Code:
Vector c = new Vector(
    (a.x + b.x) * 2.f,
    (a.y + b.y) * 2.f );

Which even if ugly can be many times faster.
In C++ and compiled languages this is a-ok to do because the compiler can easily inline stuff and put temporaries on the stack or just cancel them, so it makes something pretty much like that optimized code.

But dunno, maybe the latest JITs are able to optimize that aggressively... but I wouldn't bet.

well at least the jBox2D vectors already have add, subtract, multiply etc. as functions but they are called add, subtract etc, even things like javas native BigInteger class have those so the there is actually no difference at all.
secondly i am all alone on my current project so no one else needs to be able to compile it.
I do think about what your saying but at least for now i will probably use it.
Logged
eigenbom
Level 10
*****


@eigenbom


View Profile WWW
« Reply #3346 on: April 25, 2013, 02:37:28 PM »

@rosholger, if you use it a lot throughout your code then it's going to be very hard to redact later. I agree with those other chaps, it's not worth using it.
Logged

rosholger
Level 1
*



View Profile
« Reply #3347 on: April 26, 2013, 03:57:42 AM »

@eigenbom true, I'm still thinking about it, well see if i will actually use it or not.
Logged
jolson88
Level 0
**


View Profile
« Reply #3348 on: April 26, 2013, 06:58:41 PM »

Woot woot! Solved a problem that was absolutely BUGGING me in my code for the last several weeks (I just had bigger fish to fry until tonight when I finally decided to bite the bullet).

I have a simple MessageManager class in my code (C#) that you can register listeners with and send messages through. It is powered by generics. For example, adding a listener (before this change):

Code:
    public class MessageManager
    {
        private Dictionary<Type, Action<Message>> _messageListeners;

        ...

        public void AddListener<T>(Action<Message>> listener) where T : Message
        {
            if (!_messageListeners.Keys.Contains(typeof(T)))
            {
                _messageListeners[typeof(T)] = new List<object>();
            }

            _messageListeners[typeof(T)].Add(listener);
        }

The thing I hate about this code is that when you call AddListener, the Action you are registering is a callback that accepts the base Message type (not the derived type specified with T).

Because of variance (covariance and contravariance) in .NET Generics, Action<DerivedMessage> can't automatically cast down to Action<Message> as it is not type-safe. So, I'm left with writing ugly code that casts into the right type:

Code:
        public override void Loaded()
        {
            // Yuck, yuck, yuck! Look at those casts!
            this.GameObject.MessageManager.AddListener<CardsShuffledMessage>(msg => OnCardsShuffled((CardsShuffledMessage)msg));
            ...
        }

        private void OnCardsShuffled(CardsShuffledMessage msg)
        {
            _spriteComponent.Texture = ContentService.Instance.GetAsset<Texture2D>(AcornAssets.CardBack);
        }

Or in the above, I could have OnCardsShuffled accept just Message and cast to CardsShuffledMessage in the method body. Either way, yuck!!! This code has been bothering me big time!!!

I finally spent some time to solve it tonight. I don't think there is any way I could have solved this several years ago before I started playing around with higher-order functions in functional-programming languages (functions that return functions).

The key for me was to create a method that returned a "wrapper Action<Message>" delegate that internally did the casting to the type it knew about via generic type parameters. Then I stored listeners as List<object> instead of List<Action<Message>> to enable the more loosely-typed casting.

Code:
    public class MessageManager
    {
        private Dictionary<Type, List<object>> _messageListeners;

        // New lookup of senders that accept Action<Message> and invoke strongly-typed Action<T> in listeners
        private Dictionary<Type, Action<Message>> _messageSenders;
        ...

        // Now I can accept Action<T> (derived message listeners) rather than Action<Message>
        public void AddListener<T>(Action<T> listener) where T : Message
        {
            if (!_messageListeners.Keys.Contains(typeof(T)))
            {
                _messageListeners[typeof(T)] = new List<object>();
                _messageSenders[typeof(T)] = CreateMessageSender<T>();
            }

            _messageListeners[typeof(T)].Add(listener);
        }

        // The function that does the magic
        private Action<Message> CreateMessageSender<T>() where T : Message
        {
            return new Action<Message>(param => {
                foreach (var listener in _messageListeners[typeof(T)])
                {
                    // Do the cast to a strongly-typed action from our generic param T
                    ((Action<T>)listener)((T)param);
                }
            });
        }

        // When a message is sent to listeners, it's as simple as using the "wrapper Action" we created
        private void ProcessMessage(Message msg)
        {
            if (_messageListeners.Keys.Contains(msg.GetType()))
            {
                _messageSenders[msg.GetType()](msg);
            }
        }

Long story short, now I can write clean code that I _like_ without nasty type conversions:

Code:
// YUCK!!!! This is the code I had to write before...
//this.GameObject.MessageManager.AddListener<CardsShuffledMessage>(msg => OnCardsShuffled((CardsShuffledMessage)msg));

// YUM!!!! Much better :).
this.GameObject.MessageManager.AddListener<CardsShuffledMessage>(OnCardsShuffled);

I'm also very happy to have done this without having to resort to any reflection whatsoever. Quite ecstatic. I know I know, it's a small change, but I'm excited Tongue.
Logged

Owl X Games, high quality kid-driven games
http://www.owlxgames.com
http://www.twitter.com/owlxgames
Dr. Cooldude
Guest
« Reply #3349 on: April 29, 2013, 06:10:56 AM »

I just got DreamSpark Premium access from my school! Tears of Joy
Logged
FrankForce
Level 2
**


This tepid water is tasteless.


View Profile WWW
« Reply #3350 on: April 30, 2013, 12:24:22 PM »

I'm happy because I figured out how to show a widget with an live feed of changes to my opensource game engine. This is something I've wanted for a while but just  realized I could do it easily with an RSS feed. I'm using a plugin called "RSS Just Better" and commented out the lines of code at the bottom of the php file that were stripping the html tags and formatting from the feed. The RSS feed even has links to view a diff of the changes! Might seem like nothing to most people but I'm really happy about this and it only took about an hour of work.

You can see it working on my website in the right sidebar under "Frank Engine Updates"
http://frankforce.com/
Logged
George Michaels
Level 0
***


I like big butts and I can not lie


View Profile
« Reply #3351 on: May 01, 2013, 04:31:57 AM »

Found a bug in my network code where the client was getting packets in the reverse order that the server sent them. Found out it was my events systems fault (I handle packets with events) being FILO rather than FIFO. Fixed that, now my code makes more sense and I've future-proofed event order bugs :D
Logged

Yeah, that.
tanner bananer
Level 1
*


aspiring train conductor


View Profile WWW
« Reply #3352 on: May 04, 2013, 04:20:28 PM »

I keep surprising myself at knowing how to fix all these problems in my first program to write completely by myself.
Logged

indie11
Level 2
**


View Profile
« Reply #3353 on: May 05, 2013, 02:19:56 AM »

Optimized sprite creation using batch sprites, massive hike in FPS for low end android phones!
Logged

_Tommo_
Level 8
***


frn frn frn


View Profile WWW
« Reply #3354 on: May 07, 2013, 09:19:47 AM »

Some other multithreading C++11 proweness Wizard

Code:

worker->queueTask( [&]()
{
    load(); //load the resource
},
[&]()
{
    cout << "Loading complete!" << endl;
});

what is nice here is that the "callback function" is called on the main thread after the "fork" has finished, so no mean interleaving/whatever happens Smiley

I'm pretty happy with this threading model, it is much easier than the clumsier "create two threads and try to keep them in sync" one, and I've been able to "async" (take that as a verb) a lot of stuff in my engine.
And also threadpools!
Logged

kamac
Level 10
*****


Notoriously edits his posts


View Profile
« Reply #3355 on: May 07, 2013, 09:44:50 AM »

Some other multithreading C++11 proweness Wizard

Code:

worker->queueTask( [&]()
{
    load(); //load the resource
},
[&]()
{
    cout << "Loading complete!" << endl;
});

what is nice here is that the "callback function" is called on the main thread after the "fork" has finished, so no mean interleaving/whatever happens Smiley

I'm pretty happy with this threading model, it is much easier than the clumsier "create two threads and try to keep them in sync" one, and I've been able to "async" (take that as a verb) a lot of stuff in my engine.
And also threadpools!

I just realized that lambdas and C++11 in general, add an incredible (for me atleast) element from languages like JavaScript. Namely, they add more freedom.

JavaScript:
Code:
var func = function() { alert("!"); }
func();

C++
Code:
#include <iostream>

void main() {
    auto func = []() { std::cout << "!"; };
    func();
}

Got to love the freedom that auto combined with lambdas give!
Logged

Klaim
Level 10
*****



View Profile WWW
« Reply #3356 on: May 07, 2013, 11:09:16 AM »

Yes, it's incredibly useful in multithreaded contexts.
I implemented a system to manage objects that have to be updated serially on the same thread but without forcing a particular updating thread. That system manage the creation/destruction of the objects and provide smart pointers to manage their lifetime. But the smart pointers points not directly to the object but to a "monitor" object that let you only push function objects inside to be executed on the next object's update. No way to make this easy without lambdas.

I wish they provide quickly the std::future::then() function so that it's easier to work with future when designing these kind of systems to achieve basically what _Tommo_ was describing. Apparently it should be added to the standard next year.
Logged

Will Vale
Level 4
****



View Profile WWW
« Reply #3357 on: May 07, 2013, 02:12:25 PM »

Some other multithreading C++11 proweness Wizard
So that doesn't block the main thread, but the task queue calls the second lambda on the main thread when the first lambda (load) is complete on whatever worker thread picked it up?

Will
Logged
_Tommo_
Level 8
***


frn frn frn


View Profile WWW
« Reply #3358 on: May 07, 2013, 04:58:49 PM »

So that doesn't block the main thread, but the task queue calls the second lambda on the main thread when the first lambda (load) is complete on whatever worker thread picked it up?

Will

exactly Wizard
Logged

Will Vale
Level 4
****



View Profile WWW
« Reply #3359 on: May 08, 2013, 04:43:28 AM »

So how do you decide when to interrupt the main thread? Does the thread manager thing get ticked, and save up all the main thread lambdas to call then?

W
Logged
Pages: 1 ... 166 167 [168] 169 170 ... 279
Print
Jump to:  

Theme orange-lt created by panic