Erel B4X founder Staff member Licensed User Longtime User Aug 17, 2018 #1 A simple example of classic space invaders. Resources are based on: https://github.com/leerob/Space_Invaders/ The various objects are defined with Tiled map editor. Interesting points: - No gravity. - The lasers 'is sensor' property is checked. This way they don't push the collided object. - The enemy laser 'category bits' is set to 2. The enemies 'mask bits' is set to 65533 (Bit.And(0xffff, Bit.Not(2))). This way the enemy laser doesn't hit the enemies. - The enemies change direction when one of the enemies touches the edges. - The ship linear damping is set to a high value. This causes the ship to slow down although there is no friction. Example projects included in the examples pack: https://www.b4x.com/android/forum/threads/xui2d-example-pack.96454/ Last edited: Aug 23, 2018
A simple example of classic space invaders. Resources are based on: https://github.com/leerob/Space_Invaders/ The various objects are defined with Tiled map editor. Interesting points: - No gravity. - The lasers 'is sensor' property is checked. This way they don't push the collided object. - The enemy laser 'category bits' is set to 2. The enemies 'mask bits' is set to 65533 (Bit.And(0xffff, Bit.Not(2))). This way the enemy laser doesn't hit the enemies. - The enemies change direction when one of the enemies touches the edges. - The ship linear damping is set to a high value. This causes the ship to slow down although there is no friction. Example projects included in the examples pack: https://www.b4x.com/android/forum/threads/xui2d-example-pack.96454/
S sorex Expert Licensed User Longtime User Aug 17, 2018 #2 Sweet But it seems that java + box2d are not a good match for games like this. It pulls down an entire core for something simple like this (yes in release mode).
Sweet But it seems that java + box2d are not a good match for games like this. It pulls down an entire core for something simple like this (yes in release mode).
Erel B4X founder Staff member Licensed User Longtime User Aug 17, 2018 #3 What do you see? It runs smoothly here in 60 fps. It can temporary switch to 30 fps however it will quickly go up to 60 FPS again. You can force it to run at 30 FPS. The difference in the look and feel will be small. Add this line in Game.Initialize after X2 is initialized: Code: X2.TargetFPS = 30 Last edited: Aug 17, 2018
What do you see? It runs smoothly here in 60 fps. It can temporary switch to 30 fps however it will quickly go up to 60 FPS again. You can force it to run at 30 FPS. The difference in the look and feel will be small. Add this line in Game.Initialize after X2 is initialized: Code: X2.TargetFPS = 30
S sorex Expert Licensed User Longtime User Aug 17, 2018 #4 it only is 'static' around 30-33FPS but sometimes it shoots up to 40+ but since that goes as quick down as it went up I can't tell it it was 45 or 49.
it only is 'static' around 30-33FPS but sometimes it shoots up to 40+ but since that goes as quick down as it went up I can't tell it it was 45 or 49.
S sorex Expert Licensed User Longtime User Aug 17, 2018 #5 when I remove everything exept ivforeground & lblstats from the designer and the related code then it's constant between 58-60fps. it appears that the overlays cause a lot of slow down here even when no real alpha's are used. (I disabled a few)
when I remove everything exept ivforeground & lblstats from the designer and the related code then it's constant between 58-60fps. it appears that the overlays cause a lot of slow down here even when no real alpha's are used. (I disabled a few)
Jaames Active Member Licensed User Longtime User Aug 17, 2018 #6 Here it is running on the relatively old PC and it run flawlessly, with 2 monitors , and HD YT video on second monitor playing. and bunch of other programs in background. PC Intel i7 3770 @ 3.4Ghz 16 GB RAM NVIDIA GeForce GTX 680 Spoiler: Screenshoot I know "the like" is enough , but I have to say, thank you @Erel for amazing framework , every time you release new version it is more and more easier to use and more appealing .. And to be able to use it on all 3 major platforms without changing any code is bringing B4X tools to another level..
Here it is running on the relatively old PC and it run flawlessly, with 2 monitors , and HD YT video on second monitor playing. and bunch of other programs in background. PC Intel i7 3770 @ 3.4Ghz 16 GB RAM NVIDIA GeForce GTX 680 Spoiler: Screenshoot I know "the like" is enough , but I have to say, thank you @Erel for amazing framework , every time you release new version it is more and more easier to use and more appealing .. And to be able to use it on all 3 major platforms without changing any code is bringing B4X tools to another level..
Erel B4X founder Staff member Licensed User Longtime User Aug 18, 2018 #7 sorex said: it only is 'static' around 30-33FPS but sometimes it shoots up to 40+ but since that goes as quick down as it went up I can't tell it it was 45 or 49. Click to expand... I will write a more thorough tutorial about performance. The X2 framework will very quickly lower the drawing FPS to 30 if it cannot keep with 60 FPS (once it falls to 55 FPS). Even if it is a momentary slowdown. It will keep running in 30 FPS and try to push back to 60 FPS after a specific period. I actually plan to make some changes in the way this period is calculated. The bottom line is that it is fine if a game falls to 30 FPS. It will be a bit less smooth but should still look good.
sorex said: it only is 'static' around 30-33FPS but sometimes it shoots up to 40+ but since that goes as quick down as it went up I can't tell it it was 45 or 49. Click to expand... I will write a more thorough tutorial about performance. The X2 framework will very quickly lower the drawing FPS to 30 if it cannot keep with 60 FPS (once it falls to 55 FPS). Even if it is a momentary slowdown. It will keep running in 30 FPS and try to push back to 60 FPS after a specific period. I actually plan to make some changes in the way this period is calculated. The bottom line is that it is fine if a game falls to 30 FPS. It will be a bit less smooth but should still look good.
LucaMs Expert Licensed User Longtime User Aug 18, 2018 #8 The B4J Tutorial - B4J Change Log (version history) should be updated (6.30 --> 6.50). P.S. Ok, now I understand, 6.50 is a beta version (I saw this only now). About FPS: did you test it on Android? Not me (not even the b4j version, given that I got the message... see above ) Last edited: Aug 18, 2018
The B4J Tutorial - B4J Change Log (version history) should be updated (6.30 --> 6.50). P.S. Ok, now I understand, 6.50 is a beta version (I saw this only now). About FPS: did you test it on Android? Not me (not even the b4j version, given that I got the message... see above )
LucaMs Expert Licensed User Longtime User Aug 18, 2018 #9 LucaMs said: The B4J Tutorial - B4J Change Log (version history) should be updated (6.30 --> 6.50). About FPS: did you test it on Android? Not me (not even the b4j version, given that I got the message... see above ) Click to expand... I must say that it is not easy to find the latest versions of some libraries, in this case jBitmapCreator: Updates to internal libraries: In B4J 6.50 Beta BitmapCreator is version 4.00. In the BitmapCreator thread (which I would rename by removing "Pixels, drawing and more", leaving only "BitmapCreator"): I think the zip file names should include the version number. For the moment I could not find version 4.15 (and I suppose it is for this reason that I get errors opening the source of SpaceInvaders in b4j 6.50 beta - B2Vec2). P.S. found: Last edited: Aug 18, 2018
LucaMs said: The B4J Tutorial - B4J Change Log (version history) should be updated (6.30 --> 6.50). About FPS: did you test it on Android? Not me (not even the b4j version, given that I got the message... see above ) Click to expand... I must say that it is not easy to find the latest versions of some libraries, in this case jBitmapCreator: Updates to internal libraries: In B4J 6.50 Beta BitmapCreator is version 4.00. In the BitmapCreator thread (which I would rename by removing "Pixels, drawing and more", leaving only "BitmapCreator"): I think the zip file names should include the version number. For the moment I could not find version 4.15 (and I suppose it is for this reason that I get errors opening the source of SpaceInvaders in b4j 6.50 beta - B2Vec2). P.S. found:
Peter Simpson Expert Licensed User Longtime User Aug 18, 2018 #10 Hmm I've just seen this new post @Erel, hey congratulations on the whole XUI2D project, it's looking great. This Space Invaders game is running ridiculously smoothly and consistently at betweek 58FPS and 60FPS, and congratulations to you on me not getting past level three on my first attempt. Last edited: Aug 18, 2018
Hmm I've just seen this new post @Erel, hey congratulations on the whole XUI2D project, it's looking great. This Space Invaders game is running ridiculously smoothly and consistently at betweek 58FPS and 60FPS, and congratulations to you on me not getting past level three on my first attempt.
S sorex Expert Licensed User Longtime User Aug 18, 2018 #11 LucaMs said: About FPS: did you test it on Android? Click to expand... nope, will try it later today. but fps is one thing, cpu usage another. I don't know how I can see that on an android.
LucaMs said: About FPS: did you test it on Android? Click to expand... nope, will try it later today. but fps is one thing, cpu usage another. I don't know how I can see that on an android.
LucaMs Expert Licensed User Longtime User Aug 18, 2018 #12 sorex said: nope, will try it later today. but fps is one thing, cpu usage another. I don't know how I can see that on an android. Click to expand... Well, I think that you can reach high fps depending on cpu (and ram and other, like graphic card). I wanted to try an Android version, but I sweated to find the libraries and I do not know how much I should sweat to create the app version
sorex said: nope, will try it later today. but fps is one thing, cpu usage another. I don't know how I can see that on an android. Click to expand... Well, I think that you can reach high fps depending on cpu (and ram and other, like graphic card). I wanted to try an Android version, but I sweated to find the libraries and I do not know how much I should sweat to create the app version
LucaMs Expert Licensed User Longtime User Aug 18, 2018 #13 next challenges: 1) being able to move your spaceship even vertically; 2) - more important - add a scrolling background, to see at that point what would be the speed (fps).
next challenges: 1) being able to move your spaceship even vertically; 2) - more important - add a scrolling background, to see at that point what would be the speed (fps).
S sorex Expert Licensed User Longtime User Aug 19, 2018 #14 Luca, the new version on android starts at 58-60fps but drops after a second or 2 to 30-33. When you create a gap between the aliens and shoot there than the fps goes up to 55+ fps again till the aliens get near again. Some times when there is only the player and its bullets are left + 1 moving enemie it's also running at 30fps. It's hard to see a line in the fps decreases. But for the eye I believe that 24fps is enough to create smooth animations. Edit: forgot to mention that this is on a Huwaei P8 Lite phone Last edited: Aug 19, 2018
Luca, the new version on android starts at 58-60fps but drops after a second or 2 to 30-33. When you create a gap between the aliens and shoot there than the fps goes up to 55+ fps again till the aliens get near again. Some times when there is only the player and its bullets are left + 1 moving enemie it's also running at 30fps. It's hard to see a line in the fps decreases. But for the eye I believe that 24fps is enough to create smooth animations. Edit: forgot to mention that this is on a Huwaei P8 Lite phone
Erel B4X founder Staff member Licensed User Longtime User Aug 19, 2018 #15 I've just wrote a tutorial about XUI2D performance: https://www.b4x.com/android/forum/threads/xui2d-performance.96326/ sorex said: forgot to mention that this is on a Huwaei P8 Lite phone Click to expand... You can see the device performance score here: https://www.androidbenchmark.net/passmark_chart.html It is fine and expected that it will run at 30 fps on less powerful devices. It should still look fine.
I've just wrote a tutorial about XUI2D performance: https://www.b4x.com/android/forum/threads/xui2d-performance.96326/ sorex said: forgot to mention that this is on a Huwaei P8 Lite phone Click to expand... You can see the device performance score here: https://www.androidbenchmark.net/passmark_chart.html It is fine and expected that it will run at 30 fps on less powerful devices. It should still look fine.
LucaMs Expert Licensed User Longtime User Aug 19, 2018 #16 sorex said: the new version on android Click to expand... I have to find search for it I'm not a videogame expert, not even as a player. I always thought that to develop fast games it was necessary to work at "low level" and that the Basic was not a suitable language. All this framework probably will not reach the same speed as other approaches but it greatly simplifies development and this is probably a greater advantage in many cases. sorex said: Edit: forgot to mention that this is on a Huwaei P8 Lite phone Click to expand... Erel said: You can see the device performance score here: https://www.androidbenchmark.net/passmark_chart.html Click to expand... My benchmarks rank Huawei P8 Lite 2018 third; maybe because... it is my smartphone and I'm lying! Last edited: Aug 19, 2018
sorex said: the new version on android Click to expand... I have to find search for it I'm not a videogame expert, not even as a player. I always thought that to develop fast games it was necessary to work at "low level" and that the Basic was not a suitable language. All this framework probably will not reach the same speed as other approaches but it greatly simplifies development and this is probably a greater advantage in many cases. sorex said: Edit: forgot to mention that this is on a Huwaei P8 Lite phone Click to expand... Erel said: You can see the device performance score here: https://www.androidbenchmark.net/passmark_chart.html Click to expand... My benchmarks rank Huawei P8 Lite 2018 third; maybe because... it is my smartphone and I'm lying!
S sorex Expert Licensed User Longtime User Aug 19, 2018 #17 LucaMs said: All this framework probably will not reach the same speed as other approaches but it greatly simplifies development and this is probably a greater advantage in many cases. Click to expand... It depends what you want to do ofcourse. this Xui2D is powerfull but oh so difficult to get used to. It doesn't seem like really simplifying it code wise tho as you need to take care of a lot compared to some other (simple) 2D methods. You will also witness some unexpected side effects when you'll start experimenting with it. For example drop a box pure vertically onto another one and it will move horizontal aswell or rotate where you expect that it would just stop on top of the other one.
LucaMs said: All this framework probably will not reach the same speed as other approaches but it greatly simplifies development and this is probably a greater advantage in many cases. Click to expand... It depends what you want to do ofcourse. this Xui2D is powerfull but oh so difficult to get used to. It doesn't seem like really simplifying it code wise tho as you need to take care of a lot compared to some other (simple) 2D methods. You will also witness some unexpected side effects when you'll start experimenting with it. For example drop a box pure vertically onto another one and it will move horizontal aswell or rotate where you expect that it would just stop on top of the other one.
Erel B4X founder Staff member Licensed User Longtime User Aug 20, 2018 #18 LucaMs said: I always thought that to develop fast games it was necessary to work at "low level" and that the Basic was not a suitable language. Click to expand... B4X apps performance is similar to the performance of apps written in Java or Objective C. sorex said: You will also witness some unexpected side effects when you'll start experimenting with it. For example drop a box pure vertically onto another one and it will move horizontal aswell or rotate where you expect that it would just stop on top of the other one. Click to expand... Please start a new thread and describe any issue you encounter. This is exactly the purpose of the beta versions. About the complexity, you need to learn about Box2D in order to understand XUI2D.
LucaMs said: I always thought that to develop fast games it was necessary to work at "low level" and that the Basic was not a suitable language. Click to expand... B4X apps performance is similar to the performance of apps written in Java or Objective C. sorex said: You will also witness some unexpected side effects when you'll start experimenting with it. For example drop a box pure vertically onto another one and it will move horizontal aswell or rotate where you expect that it would just stop on top of the other one. Click to expand... Please start a new thread and describe any issue you encounter. This is exactly the purpose of the beta versions. About the complexity, you need to learn about Box2D in order to understand XUI2D.
Erel B4X founder Staff member Licensed User Longtime User Aug 20, 2018 #19 sorex said: For example drop a box pure vertically onto another one and it will move horizontal aswell or rotate where you expect that it would just stop on top of the other one. Click to expand... Not the place to discuss it but you should set the restitution to 0 if you don't want objects to bounce.
sorex said: For example drop a box pure vertically onto another one and it will move horizontal aswell or rotate where you expect that it would just stop on top of the other one. Click to expand... Not the place to discuss it but you should set the restitution to 0 if you don't want objects to bounce.