Страницы

Показаны сообщения с ярлыком blog. Показать все сообщения
Показаны сообщения с ярлыком blog. Показать все сообщения

воскресенье, 21 мая 2017 г.

How Unity notifies about innerException: rethrow in stack

Suppose code:

public void TestCodeBelowRxChainExecutedDueExceptionHandled()
        {
            UiLogger.Trace("1");
            Observable.Return(1)
                .Select(a =>
                {
                    throw new InvalidOperationException("aa");
                    return a;
                })
                .Subscribe(
                    Actions.Empty,
                    exception => Debug.LogException(new AssertionFailedException(exception, "mmm assertion failed")); // (*)
            UiLogger.Trace("2"); // not reached if not (*)
        }

четверг, 11 мая 2017 г.

Rx in Unity with favor to synchronous code

Let's look at what rx is. Someone says it's about thinking of asynchronous operations as data flows and of rx operators as flow combining operations - join, merge, concat, transform (select/selectMany), etc. I prefer thinking that way. And yes, rx is somewhat about functional programming, it can be combined with LINQ.

суббота, 6 мая 2017 г.

вторник, 10 января 2017 г.

понедельник, 4 июля 2016 г.

Building and running Android Studio gradle project on android device

Recently I was just checking out if AIDE team added support to build gradle-based projects. So, indeed they added:

AIDE also supports basic Android Studio projects, which follow the default project structure. The full gradle build system is not yet supported though
(source: http://www.android-ide.com/tutorial_androidstudio.html)

So, if your gradle setup is simple, you can just open your android project in AIDE and run.

But what to do if not? As before we have a workarond: create eclipse project files (.classpath + .project) for our project. AIDE works with eclipse project structure quite well. But what to do with the dependencies? It's insane to write all of them by hand. Likely, LibGdx enthusiasts gives us script which generates those strings for us (see for example eclipse task here)

I'll give details on example of how to build & run LibGdx gradle project in AIDE.

суббота, 30 апреля 2016 г.

MSI X99A SLI PLUS Windows 10 hang issue resolved

I've become a happy owner of MSI X99A Sli Plus mobo. I already read about many issues with asus burninng, msi burning, random Windows hangs due to problems with USB. And I want to say that I encountered nothing of that with my MSI mobo (bios 1.9, recently updated it to 1.B).

But I encountered an annoying hang for which I found a solution, so I want to share it because I don't see it anywhere on the web.

Problem: after unplugging PC from the outlet and plugging back Windows 10 hangs for the first time.
Solution: insert USB stick in one of the USB3.1 slots. You just need to keep 1 USB3.1 slot occupied to not run into that problem

четверг, 7 апреля 2016 г.

C#: Why Dictionary with hashcode as key is dangerous

Recently, I encountered following code:

        private readonly Dictionary<int, View> _listCellsForDisposal;
            if (!_listCellsForDisposal.Contains(view.GetHashCode()))
             {
                _listCellsForDisposal.Add(view.GetHashCode(), view);
             }

The intent of that code is just add item to the list if it doesn't present. But is it doing work well? It doesn't. Let's see why.

At first, let's look at the signature of GetHashCode:

public override int GetHashCode()

So, it returns int. int in c# is platform-dependent. For example int32 takes 4 bytes, it's range is:

-2,147,483,648 to 2,147,483,647

(source: https://msdn.microsoft.com/ru-ru/library/5kzh1b5w.aspx)

But how many objects can we add to the dictionary?

среда, 9 марта 2016 г.

Why static is pain

Bugs, related to static variables may be difficult to understand. I don't think it's worth investigating. As a general practice, just avoid keeping references to objects in static. When using a static reference you allways must ask youself when to free this static and when to use.

Example: keep reference to view in static variable. User closes our app, OS frees memory, so all statics are freed too. When user opens our app again, static gets newly created view. All is well.
Then, time passes and we add background running service in our app. So, when user quits our app OS can't just free memory - static may be accessed from our background service. And reference to view remains. Afterwards user open app again and static has view that was created FOR ALREADY DESTROYED VIEW HIERARCHY. And it is luck if it will work with new one. It is only one example of what can happen when using statics. Using statics is not bad. But statics need more attention from developer. They often must be freed explicitly (for example, recreated at app start). Better keep only primitive data in statics - ints, strings...

Connect to genymotion emulator from another machine via wifi

1. Change NAT to bridge in VirtualBox settings for emulator (network adapter is same used to access network using which you'll connect)
2. download adb wireless by henry (root)
3. enable debugging
4. disable all adb processes started by genymotion for emulator (I choose "use custom sdk" and then renamed adb.exe -> _adb.exe) and restart emulator
5. adb connect ip:5555
done
adb devices should say:
device (not offline)

воскресенье, 14 февраля 2016 г.

Method override in C#

Hi, everyone! Recently, I decided to put all basic info about method overriding in one place. Keeping in mind that method, which is overriden may be virtual or not. Or you may just want to make name hiding (don't know why anybody may want to do that). So, here we go.

Non-virtual methods

class A
{
    void Foo() {}
}

class B: A
{
    void Foo() {} // compiler warning B.Foo() hides A.Foo()
}
To resolve warning:
class B: A
{
    new void Foo() {} // explicitly say to compiler, that hiding is intended using "new" keyword
}

воскресенье, 6 сентября 2015 г.

Making fast performance complex animations in android

Recently, I've ran into a problem with animating item's height inside a list for some devices with poor performance. And I've done a library for that. It animates RecyclerView or ListView item's height, but isn't heavy-bounded to that containers - see on github. That animation is also known as expand-collapse animation. Here I describe main problems and solutions founded so far, which is used in library. Library is finished and I'll be very glad if you find some issues or propose pull requests.

So, let's start. To be more clear, I'll write some straightforward code which does what I'm telling about:

ValueAnimator animator = ValueAnimator.ofInt(100, 300);
animator.setDuration(1000);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
  @Override
  public void onAnimationUpdate(ValueAnimator animation) {
    listViewItem.getLayoutParams().height = (Integer) animation.getAnimatedValue();
    listViewItem.requestLayout();
  }
});
animator.start();
Many libraries, I so before, use this technique. But that is heavy because of requestLayout() - it causes layout and measure steps repeated again each call. From the other side,

суббота, 2 мая 2015 г.

LibGDX: Kotlin setup

In my previous post I wrote how to configure gradle files to increase build and open IDE speed. Those steps needs to be done if you want to configure kotlin in your libGDX project. Otherwise, you'll get really poor IDE responsiveness and even gradle daemon crashes. Assuming, that you've done all instructions from my previous post, here is the magic steps to use Kotlin. It's easy now:

1. Android Studio (AS) / IDEA -> Settings -> find by "plugin" -> Click "Jetbrains" -> find by "kotlin" -> install kotlin and kotlin for android (optional) plugins and click restart IDE to complete install plugin
2. Open core/src/main directory and create "kotlin" directory there. Recreate directories for your package, like they are in "java" directory. If your app's package is com.mycompany.mygame, then create directory com, open it, create mycompany and so on.
3. Return to IDE. You may try tools -> Kotlin -> Configure kotlin in project... or add bold lines to your core/build.gradle:

Speed up libgdx gradle build in Intellij IDEA

This article describes how to exclude running unnessary tools when building for concrete platform. Here I will make an example for desktop and Android platform, but builds for other platforms can be optimized that way too. The main idea is to move all gradle staff, related to project to it's gradle's build file. So, the way it's designed. Nothing new. While this post may be outdated, see complete and update example project on github . I'm using Android Studio, but IDEA may be used too. And yes, only gradle is here and no Eclipse. I'm a professional programmer and I believe, that Android Studio is far way better than Eclipse if it is set up well.

So, here are the steps to make IDE build fast.

Will Kotlin be the future for libGdx to target Web platform?

Currently, libgdx uses GWT plugin to target web platform. And GWT doesn't support even Java 1.6! See official docs. And it allways needs source files! (see GWT/html section in libgdx docs) It's not allways affordable.

What about Kotlin? It's robust, brand new language which is fully compatible with JVM, starting from Java 1.6+!

Let's see what's about integration in modern IDE's. Kotlin plugin for Android Studio / IDEA successfully compiles both .kt and .java files to .class! (see here and here for android)

And what about starting to code best libGDX projects in Kotlin and deploy them to web now? Now we have libgdx backends only for GWT...

What we may try now?

1. Kotlin can be converted to javascript thanks to JetBrains. Here is an example of web project, where javascript is generated from kotlin code. So, we may do that generation for now (hoping things become better in the future) and add generated javascript to GWT's web project to use with libgdx gwt backends as usual. In theory, it could work.

2. Or we may try investigating about current possibilities of Kotlin in conversion to javascript, running HTML5. Get gwt backend sources as an example and write our own backend for Kotlin's javascript and contribute to libGDX?

What will you say? Interesting, isn't it? I'll be glad to see your thoughts! Post comments, please


понедельник, 6 октября 2014 г.

I'm seeking for a job

Hello, everyone! I'm seeking for a job as a libGDX / Android / Java game developer. I'm living in Saint-Petersburg, Russia. We'll be glad to cooperate. Mailto: vnms11@gmail.com.

Here is my experience.
I'm most interested in: libGDX, cross-platform, AI, fuzzy logic, 2D game development from scratch, OpenGL, java, interesting algorithms.
Can sometimes do jobs, associated with: pure Android SDK, Python, Android NDK, jUnit, client-server, SQL.
See my old-old game on google play market.
Or my site with portfolio (sorry for advertisements there).
If you seek for commercial developments, see navigational simulator. Here I worked as a part of team for 2 years. And another 3 years I've been developing different integration software for ENOVIA V6, SmarTeam, CATIA, SolidWorks and I've been working with clients (see Dassault site).

пятница, 3 января 2014 г.

Cocos2d converting to cocos2d-x: from objective C to C++

Recently, I was following "Cocos2d Cookbook Receipts" from http://cocos2dcookbook.com/. This looks like very useful book for learning cocos2d-x for me. It is divided into receipts, so functionality in one recept doesn't use another, so it is very good for game development. It may be read in any way. So, if I want to use some receipt I had to translate it to cocos2d-x (v2.0.1 I use). Here I put translated receipts for begginers in cocos2d-x and for future suggestions. I also wrote convertor from obj C to C++.
See here:
https://github.com/Deepscorn/c2d-to-x

Receipt 2: Coloring Sprites
Features in receipt:
coloring swords,
fading to color (black).
download
I don't managed to draw gradients - I didn't find any CCGradient* class! Where are they? And I don't use any more sprites - there was another receipt for that.
Receipt 3: Animating Sprites
Features in receipt:
flying bats, gliding down, flying up and changing directions (left - right). Looks nice. Lightning!
See original receipt at http://cocos2dcookbook.com/ for more info.
I don't use Receipt.h && .mm files to simplify project. It is a receipt after all...
download

воскресенье, 12 мая 2013 г.

Старый добрый Starcraft на Android

Сколько не скачивал порты Starcraft на андроид - все какие-то глючные. Простой и надежный способ - это запустить под эмулятором Nintendo 64. Естественно, телефон нужен хотя бы arm7 и с экраном не меньше 4-х дюймов.

четверг, 3 января 2013 г.

Daggerfall на смартфоне Android


Захотелось поиграть на телефоне в Skyrim, или хотя бы Oblivion или Morrowind. Ничего не найдя задумался запустить Daggerfall - отличная возможность для неигравшего в свое время в эту замечательную игру узнать больше о вселенной Elder Scrolls!