BattleCity game using Phaser.IO, part 4 – simple collision.

In the last part we created moving player tank in our city, but it can move anywhere through the walls without any collision. So in this part we will investigate hwo to enable collision detection between our player tank and city walls. Also we will enable and outputt some debugging information to better understand what exactly happens on our map. To enable collision between our tank and walls/city  we have to enable collision for tiles ( now we will just enable collision for all tiles of our tile set ). In  create function, after add tileset, add: [code lang="js" htmlscript="true"]map.setCollisionBetween(1, 10000);[/code] Also we have to enable player tank physics, in create function, after game add sprite, we add: [code lang="js" htmlscript="true"] game.physics.enable(player_tank); player_tank.body.collideWorldBounds = true; [/code] In update function we add collision check of player vs layer: [code lang="js" htmlscript="true"] game.physics.arcade.collide(player_tank, layer); [/code] One note: after doing all this, collision still was not working. I found that it was realated to scaling. You should change layer.scale.set(2); to layer.setScale(); and it is fixed. Debugging collision. To see collision rectangles you could add [code lang="js" htmlscript="true"] layer.debug = true; [/code] after layer creation and also add a render callback function (in…

0 Comments

BattleCity game using Phaser.IO, part 3 – using Visual Studio Code.

This will be a little go back to setting up development environment. I have noticed that in some networks c9users.io is blocked by network providers firewall, that complicates developing using Cloud9 - you will net be able to preview your project. Another good tool you could use is Visual Studio Code. Download the tool, install it. As we already have our project in github, just select Clone Git repository, enter your repository url and credentials and that is it. To have a quick way of previewing of our project without moving to server you can go to Extensions, search for Live Server Extension. By pressing Go Live you will be able to quickly host your files and preview locally. Visual Studio Code has nice source control integration so you will be able to view your changes and commit and push them from UI.  

0 Comments

Creating a BattleCity game using Phaser.IO, part 1

I was never a huge fan of JavaScript and I am no way front-end developer, but I like some ideas from that technology and now with dying Flash - it is definitely the future. So in this post series, I will be making famous Nintendo (NES) Battlecity game clone using Phaser.IO, just for fun, to see how it works. To make it I decided to use some online development environment, Github for source control and .. yes that is basically all that one will need. Setting up a development environment. For a development environment, i have decided to code everything online using Cloud9 and Github. First login or create your Github account. Then create a new repository. Then you have to register for the Coud9 account and create workspace there. When creating workspace select Html5 and provide your Github repository URL in "Clone from Git.." field. Also, go to Cloud9 settings, select SSH Keys, copy your key and then go to Github->Settings->SSH and..., press New SSH key, name it something like C9 and then paste your key and press Add SSH key. Setting up project workspace. In Cloud9 workspace of your project create folders: assets->tilemaps->maps assets->tilemaps->tiles js Create empty index.html…

0 Comments

Calling .NET from PowerBuilder

To call .NET for PowerBuilder best option is to create Class Library in Visual Studio. Sign it. In project properties, Application, Assembly Information..., check "Make assembly COM-Visible". Sign it class library (project properties, Signing...). In project properties, Application, Assembly Information..., check "Make assembly COM-Visible". Optional, add these attributes to your class: [ComVisible(true)] [ClassInterface(ClassInterfaceType.AutoDual)] [ProgId("ClassLibrary1.Class1")] Register created DLL in command lime like: regasm /tlb "path/to/dll/file.dll" /codebase Use it from PowerBuilder like: [code] OLEObject obj Integer li_rc obj = CREATE OLEObject li_rc = obj.ConnectToNewObject("ClassLibrary1.Class1") IF li_rc < 0 THEN DESTROY obj MessageBox("Connecting to COM Object Failed",     "Error: " + String(li_rc)) Return MessageBox("Connecting to COM Object Failed",     "Error: " + String(li_rc)) Return Return ELSE obj.ShowMe()END IF obj.ShowMe() END IF [/code] To call some web service from this DLL you add service reference and then: [code lang="csharp"] BasicHttpBinding binding = new BasicHttpBinding(); EndpointAddress address = new EndpointAddress("http://web-service-url"); var client = new ServiceReference1.YourWebServiceClient(binding, address); var b = client.YourWebServiceMethod(); [/code]

0 Comments

List services problem in Windows 10 and PowerBuilder .NET 12.5

Windows 10 / PowerBuilder .NET 12.5 Trying to make web service client and list services I get an error: Windows SDK for .Net Framework 4.0 was not installed. Please install it before use this feature. Tried to install Microsoft Windows SDK for Windows 7 and .NET Framework 4 (ISO) but that did not help. So I downloaded ProcessMonitor to check what for PowerBuilder .NET is looking and cannot find.  Found that it is looking for [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\Windows\v7.1\WinSDK-NetFx40Tools-x86] and does not find it. In my registry, I had tools in v8.0A WinSDK-NetFx35Tools-X86, so I just for test I made this new registry entry: [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\Windows\v7.1\WinSDK-NetFx40Tools-x86] "ProductVersion"="8.0.50727" "ComponentName"="Microsoft Visual Studio 2012 Multi-targeting Utilities for .NET Framework 3.5" "InstallationFolder"="C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\bin\\" And after that, list services now work in PowerBuilder .NET 12.5        

0 Comments

PowerBuilder and Norwegian/Finish/Serbian string to date conversion on Windows 10

Problem: Problem is in system locale on Windows 10. In Windows 10 Microsoft changed date time formats for some regions: Finnish, Norwegian Bokmål (“Norway” and “Svalbard and Jan Mayen” variants), Serbian (variants “Cyrillic, Kosovo”, “Latin, Montenegro”, “Latin, Serbia” and “Latin, Kosovo”). It was internally changed so that it has now the same separator in date and time parts. For example, previously format was "01.01.2001 11:01" now is "01.01.2001 11.01". It is so even if in regional settings user sets ":" as time separator. It was reported in other systems that on Windows 10 DateTime.Parse(DateTime.Now.ToString()) no longer works correctly for described regions. More info: http://www.heikniemi.net/hardcoded/2015/08/windows-10-breaks-net-date-parsing-in-certain-locales/ Solution. As in my case system locale for users cannot be changed to any other and it is unknown if and when MS will release any fix, solution in PB should be found. My proposal would be: Create function DATE in for example w_sheet window so all other windows inherit it. public function date date (string astr_string); n_cst_datetime dtm return dtm.of_getdate(astr_string) end function Create helper function of_getdate in pfc_n_cst_datetime: public function date of_getdate (string astr_date); return Date(DateTime(astr_date)) end function So, whenever Date( data ) is called in itemchanged (or other) event, our function would be used…

0 Comments

PowerBuilder and SQL Sever ‘row changed between retrieve and update’ error.

One issue I was working on was triggering 'row changed between retrieve and update' error on DataWindowupdate. Code was kinda simple, just retrieve some values in DataWindow, move some values to Deleted buffer and then call update. No other data manipulations etc. Found that table had some database trigger that was fired on delete. Disabled the trigger and there error message was gone. So trigger was causing that. Trigger also was quite simple, just cursor going through deleted rows and selecting and updating few values in other tables. Googling told me that in Microsoft SQL server, if a table has an insert, update, or delete trigger, the number of affected rows returned to the SQLNRows property of the Transaction object after an INSERT, UPDATE, or DELETE command depends on the driver. With an ADO.NET driver, the value returned is the sum of the rows affected by the command itself and the trigger. When you are connected to Microsoft SQL Server using ADO.NET or OLE DB, you can set the RecheckRows run time database parameter (introduced in PowerBuilder 10.5) to 1 to recheck how many rows of data were affected by the INSERT, UPDATE, or DELETE command itself and return…

0 Comments

PowerBuilder – Find windows where datawindow is used

If You have a listo of datawindows and would like to make a list of windows where each of these datawindows are used, this Power-Shell function might help.By tweaking it You could search for whatewher You need, but basic concept is below.[Console]::OutputEncoding = [System.Text.Encoding]::UTF8$windowTitles = "windowsTitles.txt"New-Item $windowTitles -type file -forcefunction search ([string]$fullName) { $shortName =  [io.path]::GetFileNameWithoutExtension($fullName) $files = gci -include *.srw,*.sru,*.srd -recurse | select-string $shortName | group path | select name $found = 0 if ($files.Count -eq 0) { return 0 } foreach ($file in $files) { $shortName2 =  [io.path]::GetFileNameWithoutExtension($file.Name) if ($shortName -eq $shortName2) { continue } $found = $found + 1 Write-Host "Used in: " $shortName2 If ($file.Name.EndsWith(".srw")) { Write-Host "Used in: " $shortName2 " and its a WINDOW!" $titleString =  Get-Content $file.Name | select-string -pattern "string title = " if (-not $titleString) { Write-Host "Window has no title" Return 1 } Write-Host "Windows title is:" $titleString $title = $titleString.line.replace("string title = ","") # write title to file Add-Content -Encoding UTF8 $windowTitles $title Return 1 } Else { Return search($file.Name) } } Return $found}Use it something like this ( is same PS1 file for example ) : $files = gci -include *.srd -recurse | Where-Object {$_.FullName -like "*\$folder\*"}…

0 Comments

End of content

No more pages to load