Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

game
Started by ashutoshpanda840 Jul 12 2019 06:02 AM

4 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

ashutoshpanda840

[GLOBAL: userInfoPane.html]
ashutoshpanda840
  • Observer

  • 14 posts
  • Corona SDK

OK let me brief up the code below is different about enemy ships hovering and automatically firing.

--setting physics
local physics= require( "physics")
physics.start()
physics.setGravity(0,0)
local w,h=display.contentWidth,display.contentHeight


-- Hide status bar
display.setStatusBar( display.HiddenStatusBar )

-- Seed the random number generator
math.randomseed( os.time() )
--initializing variables
local enemyTable={}
local numEnemy=0
local mainGroup=display.newGroup()


local function loadEnemy()

        numEnemy=#enemyTable+1
        local newEnemy=display.newRect(mainGroup,w/2,20+(math.random(1,3)*30),30,30)
        newEnemy:setFillColor(1,0.2,0.2,1)
        table.insert(enemyTable,newEnemy)
        physics.addBody( newEnemy,"dynamic" )
        newEnemy.myName="enemy"
        mewEnemy:setLinearVelocity((math.random(10,70)),0)


        local function fireEnemyBullet()


            local newEnemyBullet=display.newImage(mainGroup,"enemyBullet.png",newEnemy.x,newEnemy.y)
            physics.addBody( newEnemyBullet,"dynamic" )
            newEnemyBullet.isBullet=true
            newEnemyBullet.myName="enemyBullet"
            newEnemyBullet.toBack()--keeps below the enemy shipBlast
            transition.to( newEnemyBullet,{y=h+40,time=700,onComplete=function() display.remove(newEnemyBullet) end
            })


      end

      fireEnemyBullet()


      end

      local function gameLoop()

             loadEnemy()

             for i=#enemyTable,1,-1 do--#tells the number of object in enemyTable
                  local thisEnemy=enemyTable[i]
                     if(thisEnemy.x>=w+40) then
                        display.remove( thisEnemy )
                        table.remove( enemyTable, i )
                    end
              end
      end

      timer.performWithDelay( 500, gameloop ,0 )

The code here is only part of a big program but since it was not working I tried to tried to break it down to small section to look for the actual fault now when I compile the above program  it shows no error but it show a dark screen help me out



[TOPIC: post.html]
#2

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 762 posts
  • Corona SDK

I understand that English isn't your first language, it isn't mine either, but please try to make your posts clearer and easier to understand. For instance, the title "game" doesn't explain anything and many users are just going to ignore your post because of that. I also had to read your post three times until I believe that I understood what you were saying.

 

Please read this post by roaminggamer: https://forums.coronalabs.com/topic/55780-ask-a-better-question-get-a-better-answer/



[TOPIC: post.html]
#3

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,788 posts
  • Enterprise

Are there any messages in your console log?

 

Rob



[TOPIC: post.html]
#4

ashutoshpanda840

[GLOBAL: userInfoPane.html]
ashutoshpanda840
  • Observer

  • 14 posts
  • Corona SDK

Hi for the title I literally can't understand what should I write let me explain it again actually I am trying to prepare a level 2 of the star explorer game( which is taught in corona) where in place of asteroid ship will be hovering from left to right at the same time fire bullets ,the snippet given above is part of the entire level but there was error so tried to break the code into small independent section and the code involves around the firing mechanism of enemy. I hope now you understand whats the problem now when I compile the problem what happens is the the code runs without error but the screen in simulator remains black.



[TOPIC: post.html]
#5

ashutoshpanda840

[GLOBAL: userInfoPane.html]
ashutoshpanda840
  • Observer

  • 14 posts
  • Corona SDK

To "coronaRob"  no messages please compile it yourself if you can find some problem because I am not able to find the actual problem. 




[topic_controls]
[/topic_controls]