BBC BASIC for Windows
« Sub-processes »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 11:10pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Sub-processes  (Read 430 times)
Usama Amin
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 18
xx Sub-processes
« Thread started on: Dec 1st, 2012, 3:44pm »

Hi,
I am currently working on a 2d sidescrolling shooter.
Does anyone know a way so that i can still make my character move around and at the same time, fire a projectile?
Also im a newbie coder can someone upload example code of a bullet being fired to the right of the screen until it is out of view then another can be fired?
Thanks
Usama grin
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Sub-processes
« Reply #1 on: Dec 1st, 2012, 9:53pm »

on Dec 1st, 2012, 3:44pm, Usama Amin wrote:
can someone upload example code of a bullet being fired to the right of the screen until it is out of view then another can be fired?

The very simple program below illustrates a common way of achieving that. Use the cursor keys to move the 'gun', and the space bar to fire:

Code:
      MODE 9
      ORIGIN 0,512
      GCOL 128+4
      CLG
      
      VDU 23,128,&C0,&F0,&FC,&FF,&FF,&FC,&F0,&C0
      GunX% = 0
      GunY% = 0
      BulletX% = 1280
      BulletY% = 0
      VDU 5
      
      REPEAT
        GCOL 3,9
        MOVE GunX%, GunY% : VDU 128
        GCOL 3,11
        PLOT BulletX%, BulletY%
        
        WAIT 2
        
        GCOL 3,9
        MOVE GunX%, GunY% : VDU 128
        GCOL 3,11
        PLOT BulletX%, BulletY%
        
        CASE INKEY(0) OF
          WHEN 32:
            IF BulletX% >= 1280 THEN
              BulletX% = GunX% + 32
              BulletY% = GunY% - 16
            ENDIF
          WHEN 136: GunX% -= 4
          WHEN 137: GunX% += 4
          WHEN 138: GunY% -= 4
          WHEN 139: GunY% += 4
        ENDCASE
        IF BulletX% < 1280 BulletX% += 8
      UNTIL FALSE 

For some more sophisticated examples you can look in the Games folder on the Yahoo group and on the BB4WGAMES web site:

http://tech.groups.yahoo.com/group/bb4w/files/Games/
http://bb4wgames.com/

Richard.
User IP Logged

Usama Amin
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 18
thumbup Re: Sub-processes
« Reply #2 on: Dec 1st, 2012, 10:05pm »

Thank You! grin
User IP Logged

David Williams
Developer

member is offline

Avatar

meh


PM

Gender: Male
Posts: 452
xx Re: Sub-processes
« Reply #3 on: Dec 4th, 2012, 5:54pm »

The GFXLIB package comes with a little mini-game called 'Cowboy' which happens to be all about shooting bullets!

Take a look at the code, it might give you some useful ideas.


Regards,

David.

User IP Logged

Usama Amin
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 18
xx Re: Sub-processes
« Reply #4 on: Dec 4th, 2012, 7:12pm »

Yes, i have seen it and implemented it in my game
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls