AlienInvasion | Demo Game for Mobile HTML5 Game Development | Game Engine library

 by   cykod JavaScript Version: Current License: Non-SPDX

kandi X-RAY | AlienInvasion Summary

kandi X-RAY | AlienInvasion Summary

AlienInvasion is a JavaScript library typically used in Gaming, Game Engine applications. AlienInvasion has no bugs, it has no vulnerabilities and it has low support. However AlienInvasion has a Non-SPDX License. You can download it from GitHub.

It is released under both the GPL and MIT license to do with what you will. Bit.ly link for mobile: If you make an interesting fork or enhancement of the game, let me know and it’ll get linked to here. This original repo will stay matching the code in the book.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              AlienInvasion has a low active ecosystem.
              It has 141 star(s) with 186 fork(s). There are 17 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 4 open issues and 2 have been closed. On average issues are closed in 96 days. There are 1 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of AlienInvasion is current.

            kandi-Quality Quality

              AlienInvasion has 0 bugs and 0 code smells.

            kandi-Security Security

              AlienInvasion has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              AlienInvasion code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              AlienInvasion has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              AlienInvasion releases are not available. You will need to build from source code and install.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of AlienInvasion
            Get all kandi verified functions for this library.

            AlienInvasion Key Features

            No Key Features are available at this moment for AlienInvasion.

            AlienInvasion Examples and Code Snippets

            No Code Snippets are available at this moment for AlienInvasion.

            Community Discussions

            QUESTION

            Why would just 1 column of aliens move?
            Asked 2022-Feb-25 at 15:58

            I am starting to learn Python and I'm not sure what the solution to this would be.This problem happens when i'm doing project ALien Invasion: there just 1 column of aliens moving when I run the program.

            alien_invasion.py:

            ...

            ANSWER

            Answered 2022-Feb-25 at 15:58

            Problem is self.x

            In Alien.__init__ you set self.x = float(self.rect.x) but when you create aliens then you use aliens.rect.x = ... but you don't use alien.x = float(alien.rect.x) and finally all aliens have different value in self.rect.x but the same value in self.x.

            And later in Alien.update() you set self.rect.x = self.x and it moves all aliens to the same column.

            You have to use alien.x = float(alien.rect.x) when you create alien.

            Source https://stackoverflow.com/questions/71267043

            QUESTION

            Python Crash Course -Alien Invasion -Game Ending Error
            Asked 2021-Nov-26 at 15:46

            I am working on the Alien Invasion project at the end of Python Crash Course 2nd Edition and I am having a problem with my game ending after the user runs out of lives. The game is supposed to end after all 3 lives are lost but when that happens for mine the aliens continue to move off the bottom of the screen. There are no error messages and from my many checks through the code I have entered it word for word from the book. I have worked up to the section where the scoreboard is added but now I am resetting the scoreboard which requires the game to end properly. Below is a copy of all the necessary code files that would apply to this issue. Each separate file is indicated by #filename.py and the code for said file follows. If there is anything else needed to check through this please let me know.

            ...

            ANSWER

            Answered 2021-Nov-26 at 15:46

            **Converting my comment to an answer

            original comment:

            "This is just a guess, but in your _ship_hit function you have self.stats.game_active_= False
            Should that be self.stats.game_active = False?

            it looks like you might have an extra underscore at the end"

            Source https://stackoverflow.com/questions/70126366

            QUESTION

            Using pygame.time.get_ticks() to display remaining time
            Asked 2021-Nov-19 at 01:44

            I'm currently looking to display the time remaining for power ups on my scoreboard. I'm using pygame.time.get_ticks() to determine the remaining time left for a power up and it seems to be functioning as expected. When a power up is received it lasts for 5 seconds (5000 ticks), unless the same power up is picked up again, then the time is extended by another 5 seconds. This is determined by my power level; picking up a power up increases power up level by 1, once 5 seconds pass, decrease power level by 1.

            I'm having trouble working out how to get this to properly display on my scoreboard, as currently it just displays -5000, which would be my starting power up time (0) minus my power up time allowed per level (5000). When a power up is picked up the time does not change at all and just stays at -5000.

            main.py

            ...

            ANSWER

            Answered 2021-Nov-19 at 01:44

            You are only doing the following two things once since prep_remaining_pow_time is called in init.

            Source https://stackoverflow.com/questions/70028669

            QUESTION

            Python - Alien Invasion Why don't my walls take on their shape?
            Asked 2021-Nov-16 at 06:06

            I'm currently attempting to add walls to my game that can be destroyed by both the players laser and the aliens bombs. Currently when drawing my wall to screen, it is just a single broken up line, instead of the expected shape.

            This is my first time using enumerate, and I followed along with Clear Codes Youtube video and from what I can tell my code should in theory be producing the desired shape.

            What my wall currently looks like

            walls.py

            ...

            ANSWER

            Answered 2021-Nov-15 at 23:25

            Without deeply reading the program, the core issue is likely that your shape is a single string of lines catenated together, which happens when strings are simply collected together in an argument without any separator.. while you probably intended to put commas or newlines inbetween them to form the rows of the sprite!

            current:

            Source https://stackoverflow.com/questions/69981961

            QUESTION

            Dropping power ups from destroyed aliens - Alien Invasion
            Asked 2021-Nov-14 at 22:45

            I'm currently trying to get my aliens to have a random chance to drop powerups when they are destroyed. I seem to have the basic structure and logic figure out, but I'm running into an error.

            When an alien is hit and it DOES spawn a power up, my game crashes and I'm greeted with an error.

            ...

            ANSWER

            Answered 2021-Nov-14 at 22:42

            pygame.sprite.groupcollide returns a dictionary, where the elements are a list. Therefore aliens is a list:

            pow = Pow(aliens.rect.center)

            Source https://stackoverflow.com/questions/69967545

            QUESTION

            Pygame - Alien Invasion: Making aliens shoot back
            Asked 2021-Nov-14 at 16:05

            I'm currently attempting to get my aliens to drop 'bombs' back at the player during game play. My current goal is to just get all aliens to drop bombs, then to eventually have random aliens drop bombs after a certain level.

            Currently is seems that all bombs are coming from the starting location of my first alien.

            alien_invasion.py

            ...

            ANSWER

            Answered 2021-Nov-14 at 16:05

            you need to include the x y position of the bomb in the __init__ of bombs:

            Source https://stackoverflow.com/questions/69936569

            QUESTION

            The ship does not move left or right
            Asked 2021-Sep-04 at 09:13
            import sys
            import pygame
            from pygame.sprite import Sprite
            
            class Settings:
            
                def __init__(self):
                    self.screen_width = 1200
                    self.screen_height = 800
                    self.bg_color = (230, 230, 230)
            
                    self.ship_speed = 1.5 
            
                    self.bullet_speed = 1.0
                    self.bullet_width = 3
                    self.bullet_height = 15
                    self.bullet_color = (60,60,60)
            
                    self.bullets_allowed = 3
            
            class Ship:
            
                def __init__(self, ai_game):
                    self.screen = ai_game.screen
            
                    self.settings = ai_game.settings
            
                    self.screen_rect = ai_game.screen.get_rect()
            
                    self.image = pygame.image.load('images/ship.bmp')
                    self.rect = self.image.get_rect()
            
                    self.rect.midbottom = self.screen_rect.midbottom
            
                    self.x = float(self.rect.x) 
            
                    self.moving_right = False
                    self.moving_left = False
            
            
                def update(self):
            
                    if self.moving_right and self.rect.right < self.screen_rect.right:
                        self.x += self.settings.ship_speed
                    if self.moving_left and self.rect.left > 0:
                        self.x -= self.settings.ship_speed
                    
                    self.rect.x = self.x
                        
            
            
                def blitme(self):
                    self.screen.blit(self.image, self.rect)
                
            
            class Bullet(Sprite):
            
                def __init__(self, ai_game):
                    super().__init__()
                    self.screen = ai_game.screen
                    self.settings = ai_game.settings
                    self.color = self.settings.bullet_color
                    self.rect = pygame.Rect(0, 0, self.settings.bullet_width, self.settings.bullet_height)
                    self.rect.midtop = ai_game.ship.rect.midtop
                    self.y = float(self.rect.y)
            
                def update(self):
            
                    self.y -= self.settings.bullet_speed
                    self.rect.y = self.y
            
                def draw_bullet(self):
                    pygame.draw.rect(self.screen, self.color, self.rect)
            
            class Alien(Sprite):
            
                def __init__(self, ai_game):
                    super().__init__()
            
                    self.screen = ai_game.screen
            
                    self.image = pygame.image.load('images/alien.bmp')
                    self.rect = self.image.get_rect()
            
                    self.rect.x = self.rect.width
                    self.rect.y = self.rect.height
            
                    self.x = float(self.rect.x)         
            
            
            
                       
            class AlienInvasion:
            
                def __init__(self):
                    pygame.init()
                    self.settings = Settings()
                    self.screen = pygame.display.set_mode((self.settings.screen_width, self.settings.screen_height))
                    pygame.display.set_caption("Alien Invasion")
                    self.ship = Ship(self)
                    self.bullets = pygame.sprite.Group()
                    self.aliens = pygame.sprite.Group()
            
            
                def run_game(self):
                    while True:
                        self._check_events()
                        self._update_screen()
                        self._update_bullets()
                        self._create_fleet()
            
            
                def _check_events(self):
                    for event in pygame.event.get():
                        if event.type == pygame.KEYDOWN:
                            self._check_keydown_events(event)
                        elif event.type == pygame.KEYUP:
                            self._check_keyup_events(event)    
                        elif event.type == pygame.QUIT:
                            sys.exit()
            
                def _check_keydown_events(self, event):
                    if event.key == pygame.K_RIGHT:
                        self.ship.moving_right = True
                    elif event.key == pygame.K_LEFT:
                        self.ship.moving_left = True   
                    elif event.key == pygame.K_SPACE:
                        self._fire_bullet()
                    elif event.key == pygame.K_q:
                        sys.exit()        
            
                def _check_keyup_events(self, event):
                    if event.key == pygame.K_RIGHT:
                        self.ship.moving_right = False
                    elif event.key == pygame.K_LEFT:
                        self.ship.moving_left = False    
            
                def _fire_bullet(self):
                    if len(self.bullets) <= self.settings.bullets_allowed:
                        bullet = Bullet(self)
                        self.bullets.add(bullet)
            
                def _update_bullets(self):
                    self.bullets.update()
            
                    for bullet in self.bullets.copy():
                        if bullet.rect.bottom <= 0:
                            self.bullets.remove(bullet)
            
                def _create_fleet(self):
                    alien = Alien(self)
                    self.aliens.add(alien)
            
                def _update_screen(self):
                    self.screen.fill(self.settings.bg_color)
                    self.ship.blitme()
                    for bullet in self.bullets.sprites():
                        bullet.draw_bullet()
                    self.aliens.draw(self.screen)    
                    pygame.display.flip() 
            
            
            if __name__ == '__main__':
            
                ai = AlienInvasion()
            
                ai.run_game() 
            
                 
            
                
            
            ...

            ANSWER

            Answered 2021-Sep-04 at 09:04

            Ship.update() is never called. You can call it in AlienInvasion._update_screen:

            Source https://stackoverflow.com/questions/69053797

            QUESTION

            Python: game image changes to an undesired position after adjusting image's moving speed
            Asked 2021-Jul-10 at 16:33

            I'm making a simple python game and there are 3 py files: alien_invasion, settings, ship. I would like the image position to be at the middle bottom of screen every time the game starts. It works when code are like the following:

            ...

            ANSWER

            Answered 2021-Jul-10 at 16:33

            You need to set self.x after setting the location of self.rect:

            Source https://stackoverflow.com/questions/68329625

            QUESTION

            Pygame window not popping in python using pycharm IDE
            Asked 2021-Jul-10 at 09:26

            I am currently trying to study python using the Python Crash Course book but I have halted right now because I can't go forward with the first project. Whenever I run my program in pycharm or IDLE, all I get is a message saying "pygame 2.0.1 (SDL 2.0.14, Python 3.9.6) Hello from the pygame community. https://www.pygame.org/contribute.html" with no window for the pygame popping up, my code is below, thank you for whoever can help me: EDIT: My OS is Windows 10 21H1, Currently using pycharm 2021.1 with python 3.9.6 and pygame 2.0.1

            ...

            ANSWER

            Answered 2021-Jul-10 at 09:26

            Already fixed, I tried doing another project first (one the utilizes matplot library and it was magically fixed when I tried it again.)

            Source https://stackoverflow.com/questions/68312605

            QUESTION

            Pygame.image.load Image wont be added to the screen
            Asked 2021-May-26 at 10:26

            I've tried everything to fix this, my code runs and a screen is shown but the image is not on the screen. so far I've tried:

            • putting an absolute path when entering the image in pygame.image.load
            • trying os.join.path method (file cannot be found error)
            • And loads of other things -How after trying everything, and closely following the book, i cant get it to work?
            my code from alien_invasion.py: ...

            ANSWER

            Answered 2021-May-26 at 10:26

            The image is not shown, because the display is not updated after drawing the image. Update the display after drawing the ship:

            Source https://stackoverflow.com/questions/67693980

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install AlienInvasion

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/cykod/AlienInvasion.git

          • CLI

            gh repo clone cykod/AlienInvasion

          • sshUrl

            git@github.com:cykod/AlienInvasion.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Game Engine Libraries

            godot

            by godotengine

            phaser

            by photonstorm

            libgdx

            by libgdx

            aseprite

            by aseprite

            Babylon.js

            by BabylonJS

            Try Top Libraries by cykod

            Quintus

            by cykodJavaScript

            CoderDeck

            by cykodJavaScript

            Webiva

            by cykodRuby

            StateofHTML5GameDevelopment

            by cykodJavaScript

            Spriter

            by cykodJavaScript