⬆️ ⬇️

Two extra rounds, zero penalty laps



Last week I studied the capabilities of the new Bluetooth 4.0. What for? Then, that now Apple installs it on their smartphones and tablets.

If you are the owner of a bunch of iPhone 4S and iPad Mini, then you can repeat my experiments. The rest leave a short video with a demonstration of the application. Honestly, the applications I riveted as many as 5 pieces.

The meaning of all five new applications is as simple as the Metro style - I use iPhone as a peripheral gamepad. Imagine a gamepad not only with buttons, but with a video camera and an accelerometer!

AyPad respectively plays the role of the TV on which the game unfolds.



Among other things, I posted one application in App Store, and Apple immediately approved it, to my unspeakable amazement.

About the results of weekly sales, too, will tell.





')

What you need to develop

To write my own application, I downloaded the BTLE Central Peripheral Transfer sample from my Apple site.



Threw away the apple ViewController and replaced it with about the next piece of code.

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { iPad = 0; shotView = [[ShootingViewController alloc] initWithNibName:@"ShootingViewController" bundle:nil viewController:self]; [self.view addSubview:shotView.view]; } else { iPad = 1; targetView = [[TargetViewController alloc] initWithNibName:@"TargetViewController" bundle:nil viewController:self]; [self.view addSubview:targetView.view]; } 




On the side of the iPhone, you can change the contents of the peripheralManager function, to transfer to iPad any data that is useful to you on the receiving side. These can be accelerations, video processing results, button presses, other events.



 /** Catch when someone subscribes to our characteristic, then start sending them data */ - (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central didSubscribeToCharacteristic:(CBCharacteristic *)characteristic { NSString *sendText = [NSString stringWithFormat:@"%d,%d,%d,%@", _numShots, (int) xt, (int) yt, [[UIDevice currentDevice] name]]; NSLog(@"Central subscribed to characteristic: %@", sendText); // Get the data self.dataToSend = [sendText dataUsingEncoding:NSUTF8StringEncoding]; // Reset the index self.sendDataIndex = 0; // Start sending [self sendData]; } 




I want to warn you that the amount of data transmitted at one time should not exceed 30-50 bytes. Otherwise, the connection is often lost, and packets are lost accordingly.



In addition, if the program on the iPhone processes events from the accelerometer 100 times per second, then the data on iPad should be sent no more than 10-15 times per second. Otherwise, the application may hang, the communication channel seems to be clogged, and iPad does not have time to process it.



Application Biathlon 2013









The very first one I did was biathlon application, target shooting simulator. Inspired by the victories of Malyshko and Shipulina at the World Cup, he did it in a day. Billets, though there were already, such as examples of working with the sound of shooting. Two pictures still had to borrow from the network, scale and wipe the watermarks.



The iPhone is a rifle with optics, I aim at the iPad through the optics and make a shot by clicking on the iPhone screen.



To recognize iPad geometry, I draw a bright blue line on top of the shooting range. At first I chose an orange color, but it worked only in the office environment. Houses all around are yellow lamps, and orange is just everywhere. The recognition program is unfortunately bad, just subtracting the pixel values ​​from top to bottom with the condition of the presence of the blue component. If you play in the blue and white office of Intel, then recognition does not work well.



But these are problems of the shooter; for a hint, I draw the viewer in green, which indicates the boundaries of the iPad screen.



Biathlon 2013 in App Store



I usually make all my applications free. But I insert advertising. There is no point in putting advertising into this application - there are few such people who possess a bunch of apple-based last devices.



On the other hand, if a person has new-fashioned expensive pieces of iron, then he has money. Let him buy and application. For 5 bucks, so to them, bourgeois.



I posted biathlon on the 6th for 5 bucks and forgot about it. And January 15th - rraz! - The application is approved and ready for sale.

I make a sale - otherwise no chance at all that they will notice.

3 dollars. Also fat.



Well, I think, as usual, 1-2 jumps in the first five days, then sluggish 50 jumps in a year.



But no, more horse racing. For example, today's report.

 Title Units Price Store Biathlon 2013 11 2.69 EUR DE Biathlon 2013 2 2.69 EUR FR Biathlon 2013 1 21 NOK NO Biathlon 2013 1 99 RUB RU Biathlon 2013 1 2.69 EUR SI 




I want to note that links to videos posted in app and app have no effect. As it was 50 views a week ago and left.



But from the publication on Habré 7000 views are usually typed. But there is no sense from them, you will not smear on bread.



I think this is the first app in app store using this technology. If not, correct me.



Other applications





Three-dimensional Tetris. It is based on the rotation of the iPhone, as a rigid body - I transfer one number from 24 positions, into which the figure is turned.



Digger - classic dosovsky control with iphone. Giving a click on the K4 button.



Wolfenstein. Just a shooter - passing the angle of rotation and event shot.



Darts. Imitation by iphone motion of throwing a dart. Accelerometer deflections along axes transform into displacements X - play on the target.





Most are ready for 50-90 percent and so far I am not impressed.



Yes, I forgot! Tennis! Tennis is cool! Now I will make a screenshot.







It is interesting to play tennis. On iPad, I only give the type of impact - on the left or on the right.

Source: https://habr.com/ru/post/166515/



All Articles