Is there a Physics API? šŸ¤”

Well, it looks like there was no Apple TV announcement today. Although, stand alone Apple Watch apps are on the way. Iā€™m not sure if thatā€™s something for Hype, as Iā€™m not sure if WebKit works on the Apple Watch. I thought I saw a video about it somewhere. If so, some cool retro games might be fun with Hype and Apple Watch.

It seems like Hype would be cool if it exported straight to Swift. Like, not HTML5ā€¦ straight to Swift. Now that Swift is going Open Source, maybe it makes sense. I think the problem with building games with Hype is that itā€™s not going to be as fast as a native solution.

Heh, so now Iā€™m not sure what to do. Although, itā€™s looking better. It seems that Apple is merging Mac, iOS and Watch into one development programā€¦

Apple News looked good tooā€¦

Maybe Hype is useful in that arena too.

At least I can keep busy while waiting for Hype Physics to improve.

1 Like

It looks like thereā€™s an update to Hype Reflect. It mentions an update to Physics performance. It seems like I should retry the mobile testing, to see if Hype is suitable for mobile games. The sluggish performance might have been related to Hype Reflect and not actually matter.js and Hype itself.

Iā€™m a bit sleepy now though. Ha ha. So, maybe tomorrow Iā€™ll try again.

First off, ah haā€¦ https://itunes.apple.com/us/app/pastime-baseball-for-apple/id989444591?mt=8 ā€¦I knew you guys were gamers!

Secondly, the test was successful. It was Hype Reflect that was slowing down the game on mobile. After setting up the test on my server, the performance was playable. It was a little slow on the iPhone 4, but quite smooth on my iPad Air 2.

This is good news. Itā€™s hard to design games to be built with Hype, as I donā€™t know of all the features that will be available, but it looks like I can get started on some basic games right away.

1 Like

We're taking advantage of WKWebview in Reflect, which has much better JavaScript performance. Glad to hear this speeds things up!

2 Likes

Well, the speedup was not by using Hype Reflect. I tested the project by loading it from a website.

It seems like the new WKWebview could be used to export Hype projects to mobile ā€“ another way to make Hype more of a game development platform. (Export to iOS.)

I'll have to look more into this. I've been trying to port Hype projects to Xcode. If WKWebview worked for you, it will likely speed up my projects too.

Found this article which spells out some of the differences between the two. http://blog.initlabs.com/post/100113463211/wkwebview-vs-uiwebview

The blogger also links to an app in the app store that you can test any sites performance in both webviews.

WKWebView is the way to go. Apple says so themselves...

I tried converting my UIWebKit project to a WKWebKit project. It's in Swift, so I'm not exactly sure how to update it. That seems like my project for the weekend. Yet, there is an issue. You can see it in the comments of the article you linked.

Apparently, there's a bug with loading local files with WKWebView in iOS 8. It's fixed in iOS 9. So, my project supports iOS 7. WKWebView is iOS 8, but it's better in iOS 9. So, which platform do I target? (Tumult targeted iOS 8 with their app, and it's sorta loading local files, so maybe they figured something out... but Hype is basically running a local web server for project previewing.)

This all feels so unnecessarily complicated to me. Swift is supposed to make it easier to program, but it's still a lot of lines of code to load a web page in a box. Then there's the Main.storyboard to straighten out. Currently, my project has a blue box with "UIWebView" in the middle. I'm figuring that's not the right... ViewController? ...I'm not sure of the correct terminology. What I do know is that it's pretty annoying to have to drag a blue line from a box to a line of code. That process doesn't seem very intuitive.

The video linked above focuses on the "Safari View Controller", which I'm not sure is the right solution for running Hype generated, physics based, games on iOS/Apple. I'm thinking not because it's more focused on browsing. Games are for playing. I don't need forward-back buttons or a URL bar.

Again, I think Hype should just export to iOS.

I moved a post to a new topic: XSS error when displaying document in Wordpress

1 Like

Ha, I was wondering what happened here.

So, to recap, I posted B.R.O.O.M. to my website... B.R.O.O.M. ā€“ Photics.com ...which stands for Bomb Removal & Ordnance Obliterating Machine. It's an attempt to create a game without a Physics API. In doing so, it highlights what might be good additions to a Hype Physics API.

As of version 0.1.1, I have WASD and Arrow key controls. By pressing an arrow key to move the main character, the web page itself was moving. Using the "event.preventDefault();" line stops the page from moving with the arrow keys.

window.onkeydown=function(event){

event.preventDefault();

moving = hypeDocument.isPlayingTimelineNamed('x') + hypeDocument.isPlayingTimelineNamed('y');

 if (moving == false) {
  if (event.keyCode == 37 || event.keyCode == 65) {
   if (hypeDocument.currentTimeInTimelineNamed('x') > 0) {
   hypeDocument.continueTimelineNamed('x', hypeDocument.kDirectionReverse);
   }
  } else if (event.keyCode == 38 || event.keyCode == 87) {
   if (hypeDocument.currentTimeInTimelineNamed('y') > 0) {
   hypeDocument.continueTimelineNamed('y', hypeDocument.kDirectionReverse);
   }
  } else if (event.keyCode == 39 || event.keyCode == 68) {
  hypeDocument.continueTimelineNamed('x', hypeDocument.kDirectionForward);
  } else if (event.keyCode == 40 || event.keyCode == 83) {
  hypeDocument.continueTimelineNamed('y', hypeDocument.kDirectionForward);
  }
 }
}

Key Codes:

  • Left = 37
  • Up = 38
  • Right = 39
  • Down = 40
  • A = 65
  • W = 87
  • D = 68
  • S = 83

Basically, I have two timelines. One controls the X movement and another controls the Y movement.

It's a tile based game, so I stop the timeline with keyframes.

Controls are probably a good starting point for a Physics API. B.R.O.O.M. works because minimal collision detection is necessary. So far, I stop the actor from leaving the scene by going too far up or too far to the left.

I have to figure out if I'm going to scale the whole scene or make the level changebased on the screen size. That's where the "view" in Matter.js would be handy. It's probably easier to scale the whole scene. Heh, but I'm not sure what to do with the different ratios... 3:2, 4:3 and 16:9.

I was wondering what happened to @jonathan - I posted the example, but I didn't see any feedback. Was the example bad... or perhaps it was helpful and Tumult is keeping the new physics options secret?

I did see mention of something interesting though...

It seems that Tumult does have exporting Hype projects to standalone apps on their radar. That could be another cool Pro feature.

Also, I was surprised to see that @Daniel is in New York. Are you two on different coasts? Does that hurt or help development? I'm in NYC too.

Anyway, there wasn't much progress for me this week. Maybe this weekend I'll make some more progress on my Hype game.

Another good idea for a Physics API is collision detection by type.

Exampleā€¦ if you have a tank and a helicopter, the helicopter should fly over the tank ā€“ but the projectiles from the tank should hit the helicopter.

Iā€™m not sure, but I think the terminology for this in Matter.js is collision filtering. The following thread seems relatedā€¦ https://github.com/liabru/matter-js/issues/48

1 Like

Over the weekend, I got Pac Man Championship Edition DX for iOS. Wow, time flies. I was playing it on the PS3 almost five years agoā€¦ https://photics.com/pac-man-championship-edition-dx-review/

Anyway, as Iā€™m playing this game, Iā€™m thinking in my head about Hype. If there was a physics API, could this game be made with Hype? The one feature that really stood out was the ā€œbullet-timeā€. Whenever Pac Man is about to collide with a ghost, the game slows down. Itā€™s a lot of fun. Iā€™m thinking Matter.js could do this, as it has something called ā€œTime Scalingā€.

Wow, that would be interesting with Hype. Of course, thatā€™s probably not easy to implement, as how would that work with the timeline? Yet, it if did, a whole project could be sped up or slowed down with a global ā€œTime Scalingā€ setting.

2 Likes

I recently saw mention of Hype 3.5 by @stephen in another thread. So, maybe this thread will see some action again. Is Hype working on better Physics settings?!

Also, while not quite Physics related, I think Full-Screen view should be a default option in Hype ā€“ a way to toggle between regular and full-screen modes. If Hype is going to have video game like features, full-screen is a great way to show that off.

The new Apple TV is supposedly comingā€¦

ā€¦and supposedly an SDK for third-party developers is on the way. If thatā€™s true, one of the first things Iā€™d probably look for is if ā€œWKWebKitā€ is available. Iā€™d be able to create a game once, but port it to so many different platforms.

It looks like things are about to get interesting.

Ha, that is an interesting way to do top/left movement with timelines! You'd probably want the general collision detection to be in javascript based on tiles and just allow changing direction based on that.

Sorry, the new forums are harder to track than our old ones and if I'm off the radar for a little bit I can lose posts to see or respond to!

We used to all be in SF together, but earlier this year Daniel's fiancee got a job in NYC and so he moved out there. It is nice having everyone in one office, but we have tools that help us collaborate and so it has gone pretty smooth.

Time scaling is indeed a cool feature; it'd be easy to implement (simply change the wall clock time by a multiple), but the Hype app interface would be confusing (since there'd need to be top-level keyframes for the "time" on the animation timeline!). Also for keyframe animations there's less of a need since animators have it within their control to do whatever they want.

Don't hold your breath for much difference in Physics in 3.5, sorry! The release is more focused on making lots of small improvements and Physics is a bigger item than we wanted to tackle in this specific version.

1 Like

Well, @Daniel, as Taylor Swift says... Welcome To New York.

2 Likes

Iā€™m working on the ā€œInspector: Physicsā€ section in ā€œA Book About Hypeā€, and Iā€™m noticing a few thingsā€¦

  1. Gravity (both force and angle) should be timeline properties
  2. Density, Bounce, Friction and Air Drag can be set to negative. Iā€™m thinking it probably shouldnā€™t be able to do that. Itā€™s not logical and the results are weird.
  3. Density, Bounce, Friction and Air Drag donā€™t seem to affect elements with a ā€œStaticā€ ā€œBody Typeā€. What if I wanted to make a trampoline or an icy walkway? I suppose there are other ways to do that. This is more of clarification. Is that intentional? If so, perhaps these four settings should be grayed out unless ā€œDynamicā€ is selected.
  4. There should be another setting for rotation ā€“ Allow Rotation / No Rotation. Sometimes I just want a ball to bounce up and down. With rotation, the results can be erratic.

I noticed that @jonathan mentioned this thread in another thread by @Franeko. The question was actually related to real world physics, like the accelerometer.

Itā€™s actually really easy to get accelerometer data and use it in a Hype projectā€¦

event.accelerationIncludingGravity.x

Maybe that should be part of the Hype Physics API too, but it seems too simple. This thread has been about accessing Matter.js. Iā€™ve had success working with Accelerometer data in my Hype projects. Matter.js in Hype is different. Thereā€™s so much potential there, but I canā€™t access it.

2 Likes

It looks like the Apple TV (tvOS) is on the way. Iā€™m not sure, but itā€™s looking like tvOS will support web views.

https://developer.apple.com/library/prerelease/tvos/documentation/UIKit/Reference/UIWebView_Class/index.html#//apple_ref/c/tdef/UIWebViewNavigationType

2 Likes

Heh, nope.

If this is the case that wellā€¦very disappointed. Maybe they will open it up after it has been out for awhile.ā€¦I hope