Jump to content

Search the Community

Showing results for tags 'Space Invaders'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 5 results

  1. A couple of posters have mentioned getting BabylonJS projects on to Android. This is my take on this, the whole code developed using Basic4Android (sometimes called B4A). It is a fairly mature platform - I've been using it for about 7 years now. For Basic4Android you can develop an App which creates a WebView which then loads the HTML which then loads the Javascript, which access BabylonJS. You can, obviously, send variables to the HTML (pretty standard) and/or pass variables back to the Android App - I'll leave the code in there to enable you to do that as well as I think it's quite useful to do and to see how it's been done. You WILL need some libraries, which are only available to Licensed Users (but at no extra cost). They are : WebViewExtras2 (ver 2.20) WebViewSettings (ver 1.31) JavaObject (2.05) Reflection (2.40) Phone (2.50) IME (1.10) I use other libraries in addition to these - but they are to do with Firebase / Admob and a few graphical elements. StringUtils and RuntimePermissions. B4A demo code in full. This should work, but I'm happy to help out or you can always post questions on the B4A Forum ( https://www.b4x.com/android/forum/ ). I'm using the latest release version of B4A which is 8.50 but you shouldn't necessarily need that version - probably only around 6.80 or later. #Region Project Attributes #FullScreen: True #IncludeTitle: False #ApplicationLabel: Demo #VersionCode: 1 #VersionName: 'SupportedOrientations possible values: unspecified, landscape or portrait. #SupportedOrientations: landscape #CanInstallToExternalStorage: False #End Region #Region Activity Attributes #FullScreen: True #IncludeTitle: False #End Region Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. End Sub Sub Globals 'These global variables will be redeclared each time the activity is created. 'These variables can only be accessed from this module. Dim wv As WebView Dim wve As WebViewExtras Dim wvs As WebViewSettings Private ime1 As IME Private ActivityParent As JavaObject End Sub Sub Activity_Create(FirstTime As Boolean) 'Do not forget to load the layout file created with the visual designer. For example: 'Activity.LoadLayout("Layout1") wv.Initialize("wv") wve.addWebChromeClient(wv,"wve") wvs.setAllowFileAccess(wv,True) wvs.setAppCacheEnabled(wv,True) wvs.setDOMStorageEnabled(wv,True) Activity.AddView(wv,0,0,100%x,100%y) wv.LoadUrl("file:///android_asset/index.html?parameter1="&variableValue&"") ime1.Initialize("ime1") ime1.AddHeightChangedEvent Dim jo As JavaObject = Activity jo.RunMethodJO("getContext", Null).RunMethodJO("getWindow", Null).RunMethod("setSoftInputMode", _ Array As Object(0x20)) ActivityParent = jo.RunMethodJO("getParent", Null) End Sub Sub Activity_Resume End Sub Sub Activity_Pause (UserClosed As Boolean) End Sub Sub IME1_HeightChanged (NewHeight As Int, OldHeight As Int) CallSubDelayed(Me, "AfterChange") End Sub Sub AfterChange Dim ajo As Panel = Activity Dim width As Int = ActivityParent.RunMethod("getMeasuredWidth", Null) Dim height As Int = ActivityParent.RunMethod("getMeasuredHeight", Null) If width = 0 Or height = 0 Then Return ajo.width = width 'update the "activity" width and height ajo.height = height wv.width = width wv.height = height wv.ZoomEnabled = False End Sub Sub start_rewardvideoandroidfunction (variable As String) 'Log("Got back to Android "+variable) Log("*** Got back to Android !! "& variable) End Sub Of course you will need to make sure that the HTML and Javascript reside in the correct (sub)directories. Just passing a single variable to the Javascript, but could pass more. HTML <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html" charset="utf-8"/> <title>HTML5 Demo</title> <!--- link to the last version of babylon ---> <!-- <script src="scripts/hand.minified-1.2.js" type="text/javascript"></script> --> <script src="js/pep.js" type="text/javascript"></script> <script src="js/babylon.3.1.mini.js" type="text/javascript"></script> <script src="js/babylon.gui.js" type="text/javascript"></script> <style type="text/css"> html, body { overflow: hidden; width : 100%; height : 100%; margin : 0; padding : 0; } #renderCanvas { width : 100%; height : 100%; } #scoreLabel { position:absolute; top:20px; left : 20px; color:white; font-size: 1em; } #livesLabel { position:absolute; bottom:20px; left : 20px; color:white; font-size: 1em; } #highScoreLabel { position:absolute; bottom:20px; right : 20px; color:white; font-size: 1em; } #waveLabel { position:absolute; top:20px; right : 20px; color:white; font-size: 1em; } </style> </head> <body> <canvas id="renderCanvas" touch-action="none"></canvas> <div id="scoreLabel">SCORE : 0</div> <div id="livesLabel">LIVES : </div> <div id="highScoreLabel">HIGH SCORE : </div> <div id="waveLabel">WAVE : 1</div> <script src="js/app.js" type="text/javascript"></script> <script> window.addEventListener('DOMContentLoaded', function () { var parameters = location.search.substring(1).split("&"); var temp = parameters[0].split("="); l = unescape(temp[1]); BjsApp.init(l); }); </script> </body> </html> Javascript /// <reference path="babylon.d.ts" /> /// <reference path="babylon.js" /> /// <reference path="babylon.gui.js" /> var BjsApp = BjsApp || {}; var livesP1 = 3; BjsApp.init = function (livesFromApp) { livesP1 = livesFromApp; //set here, but defined globally - not any more, passed in from Android App to allow player to get rewarded for watching an advert, gain extra life document.getElementById("livesLabel").innerHTML = "LIVES : " + livesP1; //Update the HTML div accordingly - I obviously do this quite a bit at the moment but this is mainly to save on having to code the graphical parts of those and prettify them. //Do your own Javascript stuff here!!!! console.log('The Aliens have landed about to go back to Android....'+ score); //Android.startRewardVideoAndroidFunction(score); Android.CallSub('start_rewardvideoandroidfunction',true,score); } I've, obviously, removed a whole load of code - but hopefully there should be enough here for anyone to follow. As I said I'm happy to help out or post questions on the B4A forum.
  2. I have a space invaders game that I'm trying to convert from a single javascript instantiation to state based code. I want to add a menu screen, loading screen, etc... I'm just not sure how to do it. Do I drop some of it in a Boot state and some of it in a Preload state? I was thinking the boot state would hold the create function and update function while the preload state would hold the preload function that creates the images and sprites. Any suggestions are much appreciated! Here is an example of what I'm aiming for: https://github.com/RocketshipGames/phaser-fullscreen And here is my current code: var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });function preload() { game.load.image('bullet', 'assets/games/invaders/bullet.png'); game.load.image('enemyBullet', 'assets/games/invaders/enemy-bullet.png'); game.load.spritesheet('invader', 'assets/games/invaders/invader32x32x4.png', 32, 32); game.load.image('ship', 'assets/games/invaders/player.png'); game.load.spritesheet('kaboom', 'assets/games/invaders/explode.png', 128, 128); game.load.image('starfield', 'assets/games/invaders/starfield.png'); this.load.atlasJSONHash('fullscreen', 'assets/fullscreen.png', 'assets/fullscreen.json');}var player;var aliens;var bullets;var bulletTime = 0;var cursors;var fireButton;var explosions;var starfield;var score = 0;var scoreString = '';var scoreText;var lives;var enemyBullet;var firingTimer = 0;var stateText;var livingEnemies = [];function create() { game.physics.startSystem(Phaser.Physics.ARCADE); starfield = game.add.tileSprite(0, 0, 800, 600, 'starfield'); bullets = game.add.group(); bullets.enableBody = true; bullets.physicsBodyType = Phaser.Physics.ARCADE; bullets.createMultiple(30, 'bullet'); bullets.setAll('anchor.x', 0.5); bullets.setAll('anchor.y', 1); bullets.setAll('outOfBoundsKill', true); bullets.setAll('checkWorldBounds', true); enemyBullets = game.add.group(); enemyBullets.enableBody = true; enemyBullets.physicsBodyType = Phaser.Physics.ARCADE; enemyBullets.createMultiple(30, 'enemyBullet'); enemyBullets.setAll('anchor.x', 0.5); enemyBullets.setAll('anchor.y', 1); enemyBullets.setAll('outOfBoundsKill', true); enemyBullets.setAll('checkWorldBounds', true); player = game.add.sprite(400, 500, 'ship'); player.anchor.setTo(0.5, 0.5); game.physics.enable(player, Phaser.Physics.ARCADE); aliens = game.add.group(); aliens.enableBody = true; aliens.physicsBodyType = Phaser.Physics.ARCADE; createAliens(); scoreString = 'Score : '; scoreText = game.add.text(10, 10, scoreString + score, { font: '34px Arial', fill: '#fff' }); lives = game.add.group(); game.add.text(game.world.width - 100, 10, 'Lives : ', { font: '34px Arial', fill: '#fff' }); stateText = game.add.text(game.world.centerX,game.world.centerY,' ', { font: '84px Arial', fill: '#fff' }); stateText.anchor.setTo(0.5, 0.5); stateText.visible = false; for (var i = 0; i < 3; i++) { var ship = lives.create(game.world.width - 100 + (30 * i), 60, 'ship'); ship.anchor.setTo(0.5, 0.5); ship.angle = 90; ship.alpha = 0.4; } explosions = game.add.group(); explosions.createMultiple(30, 'kaboom'); explosions.forEach(setupInvader, this); cursors = game.input.keyboard.createCursorKeys(); fireButton = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); game.scale.fullScreenScaleMode = Phaser.ScaleManager.EXACT_FIT; var fullscreen = this.add.button(this.game.width, this.game.height,'fullscreen', gofull, game.toggleFullscreen,this,'over', 'up', 'down'); fullscreen.pivot.x = fullscreen.width; fullscreen.pivot.y = fullscreen.height;}function createAliens () { for (var y = 0; y < 4; y++) { for (var x = 0; x < 10; x++) { var alien = aliens.create(x * 48, y * 50, 'invader'); alien.anchor.setTo(0.5, 0.5); alien.animations.add('fly', [ 0, 1, 2, 3 ], 20, true); alien.play('fly'); alien.body.moves = false; } } aliens.x = 100; aliens.y = 50; var tween = game.add.tween(aliens).to( { x: 200 }, 2000, Phaser.Easing.Linear.None, true, 0, 1000, true); tween.onLoop.add(descend, this);}function setupInvader (invader) { invader.anchor.x = 0.5; invader.anchor.y = 0.5; invader.animations.add('kaboom');}function descend() { aliens.y += 10;}function update() { starfield.tilePosition.y += 2; if (player.alive) { player.body.velocity.setTo(0, 0); if (cursors.left.isDown) { player.body.velocity.x = -200; } else if (cursors.right.isDown) { player.body.velocity.x = 200; } if (fireButton.isDown) { fireBullet(); } if (game.time.now > firingTimer) { enemyFires(); } game.physics.arcade.overlap(bullets, aliens, collisionHandler, null, this); game.physics.arcade.overlap(enemyBullets, player, enemyHitsPlayer, null, this); game.physics.arcade.overlap(player, aliens, playerCollision, null, this); }}function playerCollision (player,aliens){ player.kill(); live = lives.getFirstAlive(); if (live) { live.kill(); } aliens.reset(); createAliens(); var explosion = explosions.getFirstExists(false); explosion.reset(player.body.x, player.body.y); explosion.play('kaboom', 30, false, true); player.revive(); if (lives.countLiving() < 1) { player.kill(); enemyBullets.callAll('kill'); stateText.text=" GAME OVER \n Click to restart"; stateText.visible = true; game.input.onTap.addOnce(restart,this); }}function collisionHandler (bullet, alien) { bullet.kill(); alien.kill(); score += 20; scoreText.text = scoreString + score; var explosion = explosions.getFirstExists(false); explosion.reset(alien.body.x, alien.body.y); explosion.play('kaboom', 30, false, true); if (aliens.countLiving() == 0) { score += 1000; scoreText.text = scoreString + score; stateText.text = " You Won, \n Click to restart"; stateText.visible = true; enemyBullets.callAll('kill'); game.input.onTap.addOnce(restart,this); }}function enemyHitsPlayer (player,bullet) { bullet.kill(); live = lives.getFirstAlive(); if (live) { live.kill(); } var explosion = explosions.getFirstExists(false); explosion.reset(player.body.x, player.body.y); explosion.play('kaboom', 30, false, true); if (lives.countLiving() < 1) { player.kill(); enemyBullets.callAll('kill'); stateText.text=" GAME OVER \n Click to restart"; stateText.visible = true; game.input.onTap.addOnce(restart,this); }}function enemyFires () { enemyBullet = enemyBullets.getFirstExists(false); livingEnemies.length=0; aliens.forEachAlive(function(alien) { livingEnemies.push(alien); }); if (enemyBullet && livingEnemies.length > 0) { var random=game.rnd.integerInRange(0,livingEnemies.length-1); var shooter=livingEnemies[random]; enemyBullet.reset(shooter.body.x, shooter.body.y); game.physics.arcade.moveToObject(enemyBullet,player,120); firingTimer = game.time.now + 2000; }}function fireBullet () { if (game.time.now > bulletTime) { bullet = bullets.getFirstExists(false); if (bullet) { bullet.reset(player.x, player.y + 8); bullet.body.velocity.y = -400; bulletTime = game.time.now + 200; } }}function resetBullet (bullet) { bullet.kill();}function restart () { lives.callAll('revive'); aliens.removeAll(); createAliens(); player.revive(); stateText.visible = false;}function gofull() { if (game.scale.isFullScreen) { game.scale.stopFullScreen(); } else { game.scale.startFullScreen(false); }}
  3. Hi, All! Here is our new HTML5 game. Just simple space-shooter. Features: None significant Screenshots: Link: Alien Encroachers Looking for sponsorship, feel free to PM.
  4. Hello people! I've now finished a game I recently started developing, called "Matrix Invaders". The game is some kind of action side-scrolling shooter, in which your mission is to destroy the mighty enemies. But wait.. Didn't you say MATRIX!? That's right, in this game all characters are colored matrixes. You are the green one, enemies are red. Simple! How about gameplay? Well let's see: Your goal, as I said before, is to destroy the enemies. You do that by blasting them with a bullet, launced with the space button. When enough enemies have been destroyed, you'll move on to the next level, in which the difficulty is increased. The game features a total of 5 level, but let me warn you, it's pretty hard! I got the idea when trying to create a matrix rain animation, but as my computer is not much of a gaming-pc, it could on take a few drops, and the animation suddenly reminded me of Space Invaders. So I thought: "Hey! I make games, why don't I make such a game!?" And so I did.. Further more the game supports full Xbox 360 controller support in Chrome, and soon in Firefox too. I hope you'll like my game Play it here! http://games.gustavgb.dk/matrix
  5. Hi, I'm creating a shooter game, and I've followed the 'Space Invaders' example. Everything is working but one thing, I would like to have infinite ammo, so CreateMultiple has to be infinite. It requires a value, so I don't know how to make it actually infinite. Basically what I want to do is create a couple bullets and recycle them over and over again. Any suggestions on how I could do so you never run out of bullets? Thanks in advance, Kevin
×
×
  • Create New...