Moving the background

Post your coding questions such as 'how to' here.
User avatar
Wingman
Devoted Member
Posts: 594
Joined: Tue Sep 30, 2008 4:30 pm
Location: Ruudun toisella puolella

Re: Moving the background

Post by Wingman » Tue Aug 09, 2011 2:20 pm

cvirus wrote:...I want the enemies to fire so i must do somethig like this:

Code: Select all

 enemiebullet.BULLETS = New(BULLETS)
    enemiebullet\obj = CloneObject(bullet)
    CloneObjectPosition enemiebullet\obj,newenemie\obj
    CloneObjectOrientation enemiebullet\obj,newenemie\obj
    MoveObject enemiebullet\obj,24
but i´m confused in what place should i put it.

by the way, is it possible to put a variable printed in the screen with the number of enemies?

Thank you once again
You should put them around something like this (in the case you use types for enemies):

Code: Select all

repeat
    for newenemie.ENEMIES=each ENEMIES
        <moving and all that>
        if <newenemie is ready to shoot>
            enemiebullet.BULLETS=new(BULLETS)    // I think you have another type for bullets, as that'll be easier
            enemiebullet\obj = CloneObject(bullet)
            CloneObjectPosition enemiebullet\obj,newenemie\obj
            CloneObjectOrientation enemiebullet\obj,newenemie\obj
            MoveObject enemiebullet\obj,24
       endif
    next newenemie.ENEMIES
    <continuing your code>
forever
- - - -

cvirus
Newcomer
Posts: 30
Joined: Tue Jul 14, 2009 2:59 pm

Re: Moving the background

Post by cvirus » Tue Aug 09, 2011 2:35 pm

So I must create a new type like so?

Code: Select all

type ENEMBULLET
                Field obj
EndType

cvirus
Newcomer
Posts: 30
Joined: Tue Jul 14, 2009 2:59 pm

Re: Moving the background

Post by cvirus » Tue Aug 09, 2011 3:02 pm

I was able to make the enemies to fire but impossible to win such a game...lol

And the game starts to be slow

Any ideas from you masters? Should i put the enemies moving forward and shout them, i´m lost can you guys help me on the right direction?

Thank you

Code: Select all

'game space shooting

SCREEN 640, 480, cbsizable

    FrameLimit 60
    
Type ENEMIES
    Field obj
    Field health As Integer
End Type

Type BULLETS
    Field obj
End Type

Type ENEMBULLETS
    Field obj
End Type

   
Gosub load
    
Repeat
SetWindow "Ship Battle Game 1"
    For newenemie.ENEMIES = Each ENEMIES
      PointObject newenemie\obj, ship
      MoveObject newenemie\obj, 0.5
      decreasehealth = False
      
      
     ' code for enemies to fire
If decreasehealth = False Then
   enemiebullets.ENEMBULLETS =New(ENEMBULLETS)
   enemiebullets\obj = CloneObject(bullet)
            CloneObjectPosition enemiebullets\obj,newenemie\obj
            CloneObjectOrientation enemiebullets\obj,newenemie\obj
            MoveObject enemiebullets\obj,2
EndIf
For enbullet.ENEMBULLETS = Each ENEMBULLETS
        MoveObject enbullet\obj,6
 Next enbullet.ENEMBULLETS
  ' end code for enemie to fire
  
  
  
      For iBullet.BULLETS = Each BULLETS
         If ObjectsOverlap (newenemie\obj, ibullet\obj) Then
            decreasehealth = True
            DeleteObject ibullet\obj
            Delete ibullet
         EndIf
      Next ibullet
      If decreasehealth Then newenemie\health -1
      If newenemie\health < 1 Then 
      PlaySound boom,100
         DeleteObject newenemie\obj
         Delete newenemie
      EndIf
     Next newenemie.ENEMIES 
       
    CloneCameraPosition ship
        TranslateObject floor, -1.4, 0 'move the floor
                If LeftKey() Then TurnObject ship, 5
                If RightKey() Then TurnObject ship,-5
                If UpKey() Then speed# = CurveValue(4.6, speed#, 13) 'if up arrow is pressed, speed# will be increased smoothly
                If DownKey() Then speed# = CurveValue(-3.5, speed#, 13) '...and if down arrow is pressed, it will be decreased smoothly
        speed# = CurveValue (0, speed#, 60) 'this will make sure the ship will eventually stop smoothly if no key is pressed
    MoveObject ship, speed# '...and finally, the ship is actually being moved
   
     If KeyDown(cbkeyspace) And reload =0
        PlaySound shoot,20
        newbullet.BULLETS = New(BULLETS)
        newbullet\obj = CloneObject(bullet)
        CloneObjectPosition newbullet\obj,ship
        CloneObjectOrientation newbullet\obj,ship
        MoveObject newbullet\obj,24
        reload=7
     EndIf
     
SetWindow "Ship Battle Game 3"

   If Rand (1, 100) = 1 Then
      newenemie.ENEMIES = New(ENEMIES)
      newenemie\obj = CloneObject (enem)
      newenemie\health = 1
      PositionObject newenemie\obj, Rand(-220,220),Rand(-300,300)
      SetupCollision ship,newenemie\obj,2,2,1
   EndIf
     SetWindow "Ship Battle Game 4"
b=0
    For ibullet.BULLETS = Each BULLETS
     MoveObject ibullet\obj,6 
    If Distance2 (ibullet\obj,ship)>400 Then
        DeleteObject ibullet\obj
        Delete ibullet
    EndIf
b=b+1
Next ibullet

If reload >0 Then reload=reload-1

Text 30,30,"Bullets: "+b
Text 30,42,"Coordinates: X"+Int(  (ship))+", Y"+Int(ObjectY (ship))
DrawScreen 

Until EscapeKey()

load:
    shoot = LoadSound ("Blaster.wav")
    boom = LoadSound ("Boom.wav")
    
    enem = LoadObject("enemy2.png")
        ShowObject enem, 0

    bullet= LoadObject("bullet.png",72)
        ShowObject bullet, 0
        
    explosion = LoadObject("explosion.png", 72)
    ShowObject explosion, 0
    
    ship = LoadObject("nave.png", 72)
        PositionObject ship, 0, 0
       
    floor=MakeObjectFloor()
          fundo=LoadImage("fundo.bmp")
    PaintObject floor,fundo
        ClsColor cbBlack
        Color cbRed
        
For i = 1 To 15
    newenemie.ENEMIES = New(ENEMIES)
    newenemie\obj = CloneObject (enem)
    newenemie\health = 1
    PositionObject newenemie\obj, Rand(-500,500),Rand(-450,450)
    SetupCollision ship, newenemie\obj,2,2,1
Next i

    SetWindow "Ship Battle Game"     
x=0:y=0
Return
Attachments
impossible.png
impossible.png (79.36 KiB) Viewed 7532 times

cvirus
Newcomer
Posts: 30
Joined: Tue Jul 14, 2009 2:59 pm

Re: Moving the background

Post by cvirus » Wed Aug 10, 2011 4:23 pm

Any idea guys?

Anything will be appreciated.
8-)
thank you

cvirus
Newcomer
Posts: 30
Joined: Tue Jul 14, 2009 2:59 pm

Re: Moving the background

Post by cvirus » Thu Aug 11, 2011 6:35 pm

Update a little the game, still not working the shooting part correctly so i decided to disable for now, i changed the enemies sprites and add some text with number of lives but now i don´t know were to start decreasing the lives when the enemies ships collide with the main one, can anybody :P help a poor soul here.
Attachments
new.png
new.png (65.5 KiB) Viewed 7482 times

User avatar
Jonez
Devoted Member
Posts: 575
Joined: Mon Aug 27, 2007 8:37 pm

Re: Moving the background

Post by Jonez » Thu Aug 11, 2011 11:04 pm

Use Distance2()-function to get the distance between the player and the enemies. If too far, the enemies won't point to the player nor shoot, but wander aimlessly (or by waypoints if you prefer). Make an additional field for the enemies, called reload. Reload is reduced by one in each frame, and when it gets zero, the enemy is allowed to shoot again.

You can use ObjectOverlap() to check when an enemy collides with the player. Use this in the ENEMIES-loop.
-Vuoden 2008 aloittelijan ystävä -palkinnon voittaja-
Image <- protestipelikilpailun voittaja.
Space War

cvirus
Newcomer
Posts: 30
Joined: Tue Jul 14, 2009 2:59 pm

Re: Moving the background

Post by cvirus » Fri Aug 12, 2011 11:27 pm

Jonez wrote:Use Distance2()-function to get the distance between the player and the enemies. If too far, the enemies won't point to the player nor shoot, but wander aimlessly (or by waypoints if you prefer). Make an additional field for the enemies, called reload. Reload is reduced by one in each frame, and when it gets zero, the enemy is allowed to shoot again.

You can use ObjectOverlap() to check when an enemy collides with the player. Use this in the ENEMIES-loop.

Thank you Jonez, i will try that out as soon i´ll be back from 3 days weekend.

User avatar
Wingman
Devoted Member
Posts: 594
Joined: Tue Sep 30, 2008 4:30 pm
Location: Ruudun toisella puolella

Re: Moving the background

Post by Wingman » Sat Aug 13, 2011 4:08 pm

Oh, slowing down is a result for not deleting the bullets. When they get out of the play area/screen, delete them
- - - -

cvirus
Newcomer
Posts: 30
Joined: Tue Jul 14, 2009 2:59 pm

Re: Moving the background

Post by cvirus » Tue Aug 16, 2011 10:10 pm

Well i have changed some little code and here is the result, the enemies are scrolling to the left now.

Code: Select all

'game space shooting

SCREEN 640, 480, cbsizable

    FrameLimit 60
    
Type ENEMIES
    Field obj
    Field health As Integer
End Type

Type BULLETS
    Field obj
    
End Type

Type ENEMBULLETS
    Field obj
End Type


   
Gosub load
    
Repeat
SetWindow "Ship Battle Game 1"
    For newenemie.ENEMIES = Each ENEMIES
     ' PointObject newenemie\obj, ship
      MoveObject newenemie\obj, -0.5
      decreasehealth = False

      For iBullet.BULLETS = Each BULLETS
         If ObjectsOverlap (newenemie\obj, ibullet\obj) Then
            decreasehealth = True
            DeleteObject ibullet\obj
            Delete ibullet
         EndIf
      Next ibullet
      If decreasehealth Then newenemie\health -1
      If newenemie\health < 1 Then 
      PlaySound boom,100
         DeleteObject newenemie\obj
         Delete newenemie
      EndIf
     Next newenemie.ENEMIES
     
       
    CloneCameraPosition ship
        TranslateObject floor, -1.4, 0 'move the floor
                If LeftKey() Then TurnObject ship, 5
                If RightKey() Then TurnObject ship,-5
                If UpKey() Then speed# = CurveValue(4.6, speed#, 13) 'if up arrow is pressed, speed# will be increased smoothly
                If DownKey() Then speed# = CurveValue(-3.5, speed#, 13) '...and if down arrow is pressed, it will be decreased smoothly
        speed# = CurveValue (0, speed#, 60) 'this will make sure the ship will eventually stop smoothly if no key is pressed
    MoveObject ship, speed# '...and finally, the ship is actually being moved
   
     If KeyDown(cbkeyspace) And reload =0
        PlaySound shoot,20
        newbullet.BULLETS = New(BULLETS)
        newbullet\obj = CloneObject(bullet)
        CloneObjectPosition newbullet\obj,ship
        CloneObjectOrientation newbullet\obj,ship
        MoveObject newbullet\obj,24
        reload=7  
     EndIf
     
SetWindow "Ship Battle Game 3"

   If Rand (1, 100) = 1 Then
      newenemie.ENEMIES = New(ENEMIES)
      newenemie\obj = CloneObject (enem)
      newenemie\health = 1
      PositionObject newenemie\obj, Rand(-220,220),Rand(-300,300)
      SetupCollision ship,newenemie\obj,2,2,1
   EndIf
     SetWindow "Ship Battle Game 4"
b=0
    For ibullet.BULLETS = Each BULLETS
     MoveObject ibullet\obj,6 
    If Distance2 (ibullet\obj,ship)>400 Then
        DeleteObject ibullet\obj
        Delete ibullet
    EndIf
b=b+1
Next ibullet

If reload >0 Then reload=reload-1

Text 30,30,"Bullets: "+b
Text 0, 0, "Lives: "+lives
Text 30,42,"Coordinates: X"+Int(  (ship))+", Y"+Int(ObjectY (ship))
DrawScreen 

Until EscapeKey() Or lives = 0

load:
    shoot = LoadSound ("Blaster.wav")
    boom = LoadSound ("Boom.wav")
    
    enem = LoadObject("enemy2.png")
        ShowObject enem, 0

    bullet= LoadObject("bullet.png",72)
        ShowObject bullet, 0
        
    explosion = LoadObject("explosion.png", 72)
    ShowObject explosion, 0
    
    ship = LoadObject("nave.png", 72)
        PositionObject ship, 0, 0
       
    floor=MakeObjectFloor()
          fundo=LoadImage("fundo.bmp")
    PaintObject floor,fundo
        ClsColor cbBlack
        Color cbRed
        
For i = 1 To 15
    newenemie.ENEMIES = New(ENEMIES)
    newenemie\obj = CloneObject (enem)
    newenemie\health = 1
    PositionObject newenemie\obj, Rand(-500,500),Rand(-450,450)
    SetupCollision ship, newenemie\obj,2,2,1
Next i

    SetWindow "Ship Battle Game"     
x=0:y=0
lives =3
Return
The main problem is that the game is slowing down, i must put some function in the game so that way is lot easy to change the code, can anyone give some hint´s how to divide the game in functions?

Thanks :P

User avatar
valscion
Moderator
Moderator
Posts: 1585
Joined: Thu Dec 06, 2007 8:46 pm
Location: Espoo
Contact:

Re: Moving the background

Post by valscion » Tue Aug 16, 2011 10:20 pm

cvirus wrote:Well i have changed some little code and here is the result, the enemies are scrolling to the left now.

Code: Select all

---cut---
The main problem is that the game is slowing down, i must put some function in the game so that way is lot easy to change the code, can anyone give some hint´s how to divide the game in functions?

Thanks :P
The slowing down happens because you spawn new enemies and position them outside the screen. This is the problematic part:

Code: Select all

PositionObject newenemie\obj, Rand(-220,220),Rand(-300,300)
And why this is a problem? Well, you move your ship-object and clone the CAMERAs position to it. So because you move the camera, those coordinates between x: -220...220 and y: -300...300 are left behind you. To find where in the world camera is located, use functions CameraX() and CameraY(). They return the world-coordinates (those that objects use).

In my opinion your code looks fine that way and there's not an actual need for functions yet.

EDIT: You can also use the ScreenPositionObject-command to position the newly created enemies according to screen coordinates. I'd use those CameraX() and CameraY() -functions, though.
cbEnchanted, uudelleenkirjoitettu runtime. Uusin versio: 0.4.1 — Nyt myös sorsat GitHubissa!
NetMatch - se kunnon nettimättö-deathmatch! Avoimella lähdekoodilla varustettu
vesalaakso.com

cvirus
Newcomer
Posts: 30
Joined: Tue Jul 14, 2009 2:59 pm

Re: Moving the background

Post by cvirus » Tue Aug 16, 2011 10:32 pm

Once again back on the fire part, once again nothing works lol, here is my code for the enemies fire, don´t know what else should i do maybe the function parts would be nice to work on.

Code: Select all

    For newenemie.ENEMIES = Each ENEMIES
    ' PointObject newenemie\obj, ship
      MoveObject newenemie\obj, -0.5
      decreasehealth = False
If decreasehealth = False Then
    enemiebullet.ENEMBULLETS=new(ENEMBULLETS)   
            enemiebullet\obj = CloneObject(bullet)
            CloneObjectPosition enemiebullet\obj,newenemie\obj
            CloneObjectOrientation enemiebullet\obj,newenemie\obj
            
            MoveObject enemiebullet\obj,24
            
       EndIf
For enbullet.ENEMBULLETS = Each ENEMBULLETS
        MoveObject enbullet\obj,6
        PointObject enbullet\obj,ship
Next enbullet.ENEMBULLETS
Attachments
newscreen.png
newscreen.png (46.25 KiB) Viewed 7378 times

cvirus
Newcomer
Posts: 30
Joined: Tue Jul 14, 2009 2:59 pm

Re: Moving the background

Post by cvirus » Tue Aug 16, 2011 10:38 pm

VesQ wrote:
EDIT: You can also use the ScreenPositionObject-command to position the newly created enemies according to screen coordinates. I'd use those CameraX() and CameraY() -functions, though.
Use this functions instead of

Code: Select all

 PositionObject newenemie\obj, Rand(-500,500),Rand(-450,450)
and this?

Code: Select all

 PositionObject newenemie\obj, Rand(-220,220),Rand(-300,300)

Any code example for that?

Thank you

User avatar
valscion
Moderator
Moderator
Posts: 1585
Joined: Thu Dec 06, 2007 8:46 pm
Location: Espoo
Contact:

Re: Moving the background

Post by valscion » Wed Aug 17, 2011 9:51 am

cvirus wrote:
VesQ wrote:
EDIT: You can also use the ScreenPositionObject-command to position the newly created enemies according to screen coordinates. I'd use those CameraX() and CameraY() -functions, though.
Use this functions instead of

Code: Select all

 PositionObject newenemie\obj, Rand(-500,500),Rand(-450,450)
and this?

Code: Select all

 PositionObject newenemie\obj, Rand(-220,220),Rand(-300,300)

Any code example for that?

Thank you
You need to add (or decrease, I'm not sure) the values of CameraX() and Y() from those coordinates. So like this:

Code: Select all

PositionObject newenemie\obj, Rand(-220,220) + CameraX(), Rand(-300,300) + CameraY()
cbEnchanted, uudelleenkirjoitettu runtime. Uusin versio: 0.4.1 — Nyt myös sorsat GitHubissa!
NetMatch - se kunnon nettimättö-deathmatch! Avoimella lähdekoodilla varustettu
vesalaakso.com

cvirus
Newcomer
Posts: 30
Joined: Tue Jul 14, 2009 2:59 pm

Re: Moving the background

Post by cvirus » Wed Aug 17, 2011 3:27 pm

Better and faster now, the other problem now is the enemies shooting part.

my code for enemies shooting:

Code: Select all

[code]    For newenemie.ENEMIES = Each ENEMIES
    ' PointObject newenemie\obj, ship
      MoveObject newenemie\obj, -0.5
      decreasehealth = False
If decreasehealth = False Then
    enemiebullet.ENEMBULLETS=new(ENEMBULLETS)   
            enemiebullet\obj = CloneObject(bullet)
            CloneObjectPosition enemiebullet\obj,newenemie\obj
            CloneObjectOrientation enemiebullet\obj,newenemie\obj
            
            MoveObject enemiebullet\obj,24
            
       EndIf
       
For enbullet.ENEMBULLETS = Each ENEMBULLETS
        MoveObject enbullet\obj,6
        PointObject enbullet\obj,ship
      If Distance2(newenemie\obj,ship)< 50
      DeleteObject enbullet\obj
      Delete enbullet
      EndIf
Next enbullet.ENEMBULLETS
[/code]

the enemies can only shoot if neer the ship and not from any position but my code doesn´t work.

User avatar
Jonez
Devoted Member
Posts: 575
Joined: Mon Aug 27, 2007 8:37 pm

Re: Moving the background

Post by Jonez » Wed Aug 17, 2011 4:41 pm

I'm not sure what that code is supposed to do... But here's how I would do it:

Code: Select all

For ienemy.ENEMIES = Each ENEMIES
    If Distance2( ienemy\obj, playerShip ) < 500 //enemy is close enough
        PointObject ienemy\obj, playerShip
        
        nbullet.BULLETS = New( BULLETS )
        nbullet\obj = CloneObject( objMasterBullet )
        CloneObjectPosition nbullet\obj, ienemy\obj
        CloneObjectOrientation nbullet\obj, ienemy\obj
        
    Else
        MoveEnemyRandomly()
    EndIf
Next ienemy

For ibullet.BULLETS = Each BULLETS
    MoveObject ibullet\obj, 5
    
    If ObjectsOverlap( ibullet\obj, playerShip, 2 ) Then
        DeleteObject ibullet\obj
        Delete ibullet
        
        playerHealth - 5
    EndIf
Next ibullet
Oh yeah and of course the shooting would have a reload-function. Forgot that.
-Vuoden 2008 aloittelijan ystävä -palkinnon voittaja-
Image <- protestipelikilpailun voittaja.
Space War

cvirus
Newcomer
Posts: 30
Joined: Tue Jul 14, 2009 2:59 pm

Re: Moving the background

Post by cvirus » Wed Aug 17, 2011 8:29 pm

I´m desperate because i have tried almost everything ans for some reason everything goes wrong, i´m confused a lot with this, where is my code, if any of you guys can point where in the code i´m doing it bad?

Code: Select all

SCREEN 640, 480, cbsizable

    FrameLimit 60
    
Type ENEMIES
    Field obj
    Field health As Integer
End Type

Type BULLETS
    Field obj
    
End Type

Type ENEMBULLETS
    Field obj
End Type


   
Gosub load
    
Repeat
SetWindow "Ship Battle Game 1"
    For newenemie.ENEMIES = Each ENEMIES
     PointObject newenemie\obj, ship
      MoveObject newenemie\obj, -0.5
      decreasehealth = False
If decreasehealth = False Then
    enemiebullet.ENEMBULLETS=new(ENEMBULLETS)   
            enemiebullet\obj = CloneObject(bullet)
            CloneObjectPosition enemiebullet\obj,newenemie\obj
            CloneObjectOrientation enemiebullet\obj,newenemie\obj
            
            MoveObject enemiebullet\obj,24
            
       EndIf
       
For enbullet.ENEMBULLETS = Each ENEMBULLETS
If Distance2(newenemie\obj,ship)< 500
      MoveObject enbullet\obj,6
      EndIf
Next enbullet.ENEMBULLETS

      For iBullet.BULLETS = Each BULLETS
         If ObjectsOverlap (newenemie\obj, ibullet\obj) Then
            decreasehealth = True
            DeleteObject ibullet\obj
            Delete ibullet
         EndIf
      Next ibullet
      If decreasehealth Then newenemie\health -1
      If newenemie\health < 1 Then 
      PlaySound boom,100
         DeleteObject newenemie\obj
         Delete newenemie
      EndIf
     Next newenemie.ENEMIES
     
       
    CloneCameraPosition ship
        TranslateObject floor, -1.4, 0 'move the floor
                If LeftKey() Then TurnObject ship, 5
                If RightKey() Then TurnObject ship,-5
                If UpKey() Then speed# = CurveValue(4.6, speed#, 13) 'if up arrow is pressed, speed# will be increased smoothly
                If DownKey() Then speed# = CurveValue(-3.5, speed#, 13) '...and if down arrow is pressed, it will be decreased smoothly
        speed# = CurveValue (0, speed#, 60) 'this will make sure the ship will eventually stop smoothly if no key is pressed
    MoveObject ship, speed# '...and finally, the ship is actually being moved
   
     If KeyDown(cbkeyspace) And reload =0
        PlaySound shoot,20
        newbullet.BULLETS = New(BULLETS)
        newbullet\obj = CloneObject(bullet)
        CloneObjectPosition newbullet\obj,ship
        CloneObjectOrientation newbullet\obj,ship
        MoveObject newbullet\obj,24
        reload=7  
     EndIf
     
SetWindow "Ship Battle Game 3"

   If Rand (1, 100) = 1 Then
      newenemie.ENEMIES = New(ENEMIES)
      newenemie\obj = CloneObject (enem)
      newenemie\health = 1
      PositionObject newenemie\obj, Rand(-220,220)+ CameraX(),Rand(-300,300)+ CameraY()
      SetupCollision ship,newenemie\obj,2,2,1
   EndIf
     SetWindow "Ship Battle Game 4"
b=0
    For ibullet.BULLETS = Each BULLETS
     MoveObject ibullet\obj,6 
    If Distance2 (ibullet\obj,ship)>400 Then
        DeleteObject ibullet\obj
        Delete ibullet
    EndIf
b=b+1
Next ibullet

If reload >0 Then reload=reload-1

Text 30,30,"Bullets: "+b
Text 0, 0, "Lives: "+lives
Text 30,42,"Coordinates: X"+Int(  (ship))+", Y"+Int(ObjectY (ship))
DrawScreen 

Until EscapeKey() Or lives = 0

load:
    shoot = LoadSound ("Blaster.wav")
    boom = LoadSound ("Boom.wav")
    
    enem = LoadObject("enemy2.png")
        ShowObject enem, 0

    bullet= LoadObject("bullet.png",72)
        ShowObject bullet, 0
        
    explosion = LoadObject("explosion.png", 72)
    ShowObject explosion, 0
    
    ship = LoadObject("nave.png", 72)
        PositionObject ship, 0, 0
       
    floor=MakeObjectFloor()
          fundo=LoadImage("fundo.bmp")
    PaintObject floor,fundo
        ClsColor cbBlack
        Color cbRed
        
For i = 1 To 15
    newenemie.ENEMIES = New(ENEMIES)
    newenemie\obj = CloneObject (enem)
    newenemie\health = 1
    PositionObject newenemie\obj, Rand(-500,500)+ CameraX(),Rand(-450,450)+CameraY()
    SetupCollision ship, newenemie\obj,2,2,1
Next i

    SetWindow "Ship Battle Game"     
x=0:y=0
lives =3
Return
:?:

cvirus
Newcomer
Posts: 30
Joined: Tue Jul 14, 2009 2:59 pm

Re: Moving the background

Post by cvirus » Sun Aug 21, 2011 6:16 pm

Any idea guys?

Thanks :D

User avatar
Jonez
Devoted Member
Posts: 575
Joined: Mon Aug 27, 2007 8:37 pm

Re: Moving the background

Post by Jonez » Sun Aug 21, 2011 8:02 pm

Well there really isn't a proper question in your post. I gave you a perfectly valid example on how to make a working model for shooting enemies. It seems you haven't even tried to use it in your code (I could be wrong). If my example isn't what you are looking for for your game, please tell us, and in more detail of what you really want.

We don't have the media for your game so we could try it (and no, we won't make our own). Moreover, your code isn't as clean as it could be. The indentation could be more systematic. This won't motivate us to search mistakes.

The point is: don't ask if we could tell everything that's wrong (and then possibly fix it for you). State your problem and ask a proper question about one topic only. There is no team of helpers behind the screen. We do this in our own time. If we're arsed to.

So, as far as I can see, you problem still lies in the enemy shooting (for one). And to that question I already gave an answer.

If your code is a complete mess, or it just could be better, there is no shame in starting all over. I mean, just look at the example Zero has given us with Coolbasic.
-Vuoden 2008 aloittelijan ystävä -palkinnon voittaja-
Image <- protestipelikilpailun voittaja.
Space War

cvirus
Newcomer
Posts: 30
Joined: Tue Jul 14, 2009 2:59 pm

Re: Moving the background

Post by cvirus » Sun Aug 21, 2011 10:19 pm

Thank you for the reply Jonez, you are absolutely right, I will start all over with the examples you guys gave me here and thru the CoolBasic examples too, and then if the mistake continues i will open a new post with the proper questions.

Thanks ans sorry for the abuse.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest