an attempt to create a Tamagotchi cat program

Game development specific discussions.
ron77
Posts: 213
Joined: Feb 21, 2019 19:24

an attempt to create a Tamagotchi cat program

Post by ron77 »

hello everyone...

well i'm still at the very beginner level in game-dev sad to say. i tried "let's build a roguelike game" tutorial yet i can't seem to fully understand the manifestation of the concept into the logic of every line of code as long as i copy/paste the code examples everything works fine and can even understand enough to modify it a bit yet - that's not really learning cause if i would have to code the whole game by myself i wouldn't know how...

so i thought about starting with something simple - very simple a Tamagotchi program of a cat so i created an cat object (kinda) and here is the result for you - any advice as to how and what to add to it or what to modify in it will be greatly appreciated... the program uses fbsound to play a .wav file of some cat meawo sound and does basic animation...

file "cat_obj.bi"

Code: Select all

#INCLUDE ONCE "fbsound_dynamic.bi"


'ENUM poses
'   poses1
'   poses2
'   poses3
'END ENUM

TYPE cat
   x AS integer
   DECLARE SUB CP(row AS INTEGER, s AS STRING)
   DECLARE SUB display_screen(index AS INTEGER)
   'DECLARE SUB make_sound(f AS STRING, t AS integer)
   DECLARE SUB animation(f AS STRING, t AS INTEGER)
END TYPE

SUB cat.CP(row AS INTEGER, s AS STRING)
   LOCATE row, (100 - LEN(s)) / 2 : PRINT s
END SUB

SUB cat.display_screen(index AS integer)
   
   SELECT CASE index
      CASE 0:
         CLS
   CP 4, "^                        ^"
   CP 5, "( ) %%%%%%%%%%%%%%%%%%%  ( )"
   CP 6, "<| (( <|> ))  ||   ((  <|>  )) |>"
   CP 7, "_                              _"
   CP 8, "_                            _"
   CP 9, "_    >(::| * |::)<     _"
   CP 10, "        -------          "
   CP 11, "(  -----  )"
   CP 12, "\\---//"
   CP 13, "%%%"
      CASE 1:
         CLS
   CP 4, "^                        ^"
   CP 5, "( ) %%%%%%%%%%%%%%%%%%%  ( )"
   CP 6, "<| (( <I> ))  ||   ((  <I>  )) |>"
   CP 7, "_                              _"
   CP 8, "_                            _"
   CP 9, "_    >(::| * |::)<     _"
   CP 10, "                          "
   CP 11, "(  OOOO  )"
   CP 12, "\\   //"
   CP 13, "%%%"
      CASE 2:
         cls
   CP 4, "^                        ^"
   CP 5, "( ) %%%%%%%%%%%%%%%%%%%  ( )"
   CP 6, "<| (( <dOb> ))  ||   ((  <dOb>  )) |>"
   CP 7, "_                              _"
   CP 8, "_                            _"
   CP 9, "_    >(::| & |::)<     _"
   CP 10, "                          "
   CP 11, "(  ~~~~~  )"
   CP 12, "\\ ~~~ //"
   CP 13, "%%%"
   END SELECT
END SUB

SUB CAT.ANIMATION(f AS STRING, t AS INTEGER)
   DIM i AS INTEGER = 0
   DIM AS Integer hWave
	fbs_Load_WAVFile(f , @hWave)
	fbs_Play_Wave(hWave , t)
   DO
      IF i >= 3 THEN i = 0
      DISPLAY_SCREEN(i)
      SLEEP 500
      i += 1
      
   LOOP UNTIL INKEY <> ""
   fbs_Destroy_Wave(@hWave)
END SUB

'SUB cat.make_sound(f AS STRING, t AS INTEGER)
'   DIM AS Integer hWave
'	fbs_Load_WAVFile(f , @hWave)
'	fbs_Play_Wave(hWave , t)
'	SLEEP
'  While Inkey <> "":WEND
'	fbs_Destroy_Wave(@hWave)
'END SUB

IF fbs_Init()=false then
  print "error: FBS_INIT() " & FBS_Get_PlugError()
  beep : sleep : end 1
end IF


DIM SHARED fiori AS cat


file "main.bas"

Code: Select all

#INCLUDE ONCE "cat_obj.bi"
SCREEN 19


'fiori.make_sound("cat_sound.wav", 1)

fiori.animation("cat_sound.wav", 1)
ron77
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: an attempt to create a Tamagotchi cat program

Post by BasicCoder2 »

@ron77
Ran program,
error: lib fbsound-32 not loaded !

The last time I used sound was with #include "audio.bi" .

Are you using Linux or Windows?

I would need to get the sound working (or use audio.bi) before suggesting how and what to add to it or what to modify.

Also I would use a generic modular game structure like,

load and/or initialize data
main:
updateData()
displayData()
loop
cleanUp

Quickly drew up a little cat animation using MSPAINT which I think is easier and desirable in the future in a better game than using ascii pics.
You would have to convert the attached .png to .bmp to work with code below

Code: Select all

screenres 640,480,32
color rgb(0,0,0),rgb(255,255,255):cls
dim shared as any ptr catSheet   'create pointer
catSheet = imagecreate(1168,200) 'point at new bitmap
bload "catSheet.bmp",catSheet    'load image into bitmap

dim shared as integer frame      'current animation frame

dim as double st   'start of time
st = TIMER         'st = current time

do
    if TIMER-st > 0.05 then  'next frame
        st = TIMER            'reset start
        screenlock
        cls
        put (320,140),catSheet,(frame*146,0)-(frame*146+145,145),trans
        screenunlock
        frame = frame + 1   'next frame
        if frame = 8 then frame = 0
    end if
    sleep 2
loop until multikey(&H01)  'loop until ESC keypress

Image
ron77
Posts: 213
Joined: Feb 21, 2019 19:24

Re: an attempt to create a Tamagotchi cat program

Post by ron77 »

thank you so much basicCoder2 :)

for the replay and code example - i will study the code and will try to make the most out of it. i use windows the sound works with fbsound library

ron77
Imortis
Moderator
Posts: 1924
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: an attempt to create a Tamagotchi cat program

Post by Imortis »

Ideas:

Make the cat get hungry and need food. You can make a number to track the cats hunger, a function to reset the number to max by feeding it, and use the current time to decide how hungry it should be.

Make the can need to sleep every so often.

Pet the cat to keep it happy.
xywhsoft
Posts: 74
Joined: Aug 28, 2009 6:28
Contact:

Re: an attempt to create a Tamagotchi cat program

Post by xywhsoft »

A little advice may help you.

The key to making games is not how to draw pictures, but how to management games all kinds of data.

What is the data when the game is still? I clicked on how the data of the game will change. Drawing just shows this process.

It's not a game to draw a few pictures on the screen, but you can manipulate data dynamically, even if you finally let some characters fight on the screen, it can be fun.

Learn to think first, until you can understand the object-oriented programming, and make your own simple data model, then you can develop the game.
ron77
Posts: 213
Joined: Feb 21, 2019 19:24

Re: an attempt to create a Tamagotchi cat program

Post by ron77 »

hello imortis...

here is a add on to the "cat_obj.bi" UDT object i added the hunger index when the cat is hungry and should be feed... this took me hours :(

file "cat_obj.bi"

Code: Select all

#INCLUDE ONCE "fbsound_dynamic.bi"

DIM SHARED AS long hWave
DIM SHARED isOut AS boolean = FALSE
DIM SHARED text1 AS STRING
DIM SHARED text2 AS STRING
DIM SHARED AS INTEGER hunger
'hunger = INT(RND*101)
'ENUM poses
'   poses1
'   poses2
'   poses3
'END ENUM

TYPE cat
   isOut AS boolean
   hunger AS integer
   DECLARE SUB CP(row AS INTEGER, s AS STRING)
   DECLARE SUB display_screen(index AS INTEGER)
   DECLARE SUB make_sound(f AS STRING, t AS integer)
   DECLARE SUB animation(f AS STRING, t AS INTEGER)
   DECLARE SUB cat_hunger()
   DECLARE CONSTRUCTOR()
   DECLARE DESTRUCTOR()
   
END TYPE

CONSTRUCTOR cat
   'isOut = FALSE
   'hunger = INT(RND*101)
END CONSTRUCTOR

DESTRUCTOR cat

END DESTRUCTOR



SUB cat.CP(row AS INTEGER, s AS STRING)
   LOCATE row, (100 - LEN(s)) / 2 : PRINT s
END SUB

SUB cat.display_screen(index AS integer)
   
   SELECT CASE index
      CASE 0:
         CLS
   CP 4, "^                        ^"
   CP 5, "( ) %%%%%%%%%%%%%%%%%%%  ( )"
   CP 6, "<| (( <|> ))  ||   ((  <|>  )) |>"
   CP 7, "_                              _"
   CP 8, "_                            _"
   CP 9, "_    >(::| * |::)<     _"
   CP 10, "        -------          "
   CP 11, "(  -----  )"
   CP 12, "\\---//"
   CP 13, "%%%"
   CP 34, text1
   CP 35, text2
      CASE 1:
         CLS
   CP 4, "^                        ^"
   CP 5, "( ) %%%%%%%%%%%%%%%%%%%  ( )"
   CP 6, "<| (( <I> ))  ||   ((  <I>  )) |>"
   CP 7, "_                              _"
   CP 8, "_                            _"
   CP 9, "_    >(::| * |::)<     _"
   CP 10, "                          "
   CP 11, "(  OOOO  )"
   CP 12, "\\   //"
   CP 13, "%%%"
   CP 34, text1
   CP 35, text2
      CASE 2:
         cls
   CP 4, "^                        ^"
   CP 5, "( ) %%%%%%%%%%%%%%%%%%%  ( )"
   CP 6, "<| (( <dOb> ))  ||   ((  <dOb>  )) |>"
   CP 7, "_                              _"
   CP 8, "_                            _"
   CP 9, "_    >(::| & |::)<     _"
   CP 10, "                          "
   CP 11, "(  ~~~~~  )"
   CP 12, "\\ ~~~ //"
   CP 13, "%%%"
   CP 34, text1
   CP 35, text2
   END SELECT
END SUB

'SUB CAT.ANIMATION(f AS STRING, t AS INTEGER)
'   start:
'   DIM i AS INTEGER = 0
'   make_sound(f, t)
'	hunger = INT(RND*101)
'   DO
'      IF i >= 3 THEN i = 0
'      DISPLAY_SCREEN(i)
'      SLEEP 500
'      i += 1
'      cat_hunger(hunger)
'         
'      ENDIF
'   LOOP UNTIL INKEY <> ""
'   fbs_Destroy_Wave(@hWave)
'   SLEEP 1000
'   GOTO start
'END SUB

SUB cat.cat_hunger()
   'start:
   'hunger = INT(RND*101)
   'DO
      text1 = "cat hunger is: " & hunger
      IF hunger < 27 THEN text2 = "cat is hungry! press any key to feed it"
      IF hunger >= 25 THEN
         hunger -= 1
      ELSEIF hunger <= 25 THEN
         'text2 = "cat is hungry! press any key to feed it"
         
         isOut = TRUE
         
      ENDIF
   'LOOP
   'GOTO start
   
END SUB



SUB cat.make_sound(f AS STRING, t AS INTEGER)
   'DIM AS Integer hWave
	fbs_Load_WAVFile(f , @hWave)
	fbs_Play_Wave(hWave , t)
	'SLEEP
  'While Inkey <> "":WEND
'	fbs_Destroy_Wave(@hWave)
END SUB

SUB CAT.ANIMATION(f AS STRING, t AS INTEGER)
   
   DO
   isOut = FALSE
   DIM i AS INTEGER = 0
   make_sound(f, t)
	hunger = INT(RND*801)
   DO
      IF i >= 3 THEN i = 0
      DISPLAY_SCREEN(i)
      SLEEP 500
      i += 1
      cat_hunger()
         IF isOut = TRUE THEN EXIT DO
       
         
      
   LOOP UNTIL INKEY <> ""
   fbs_Destroy_Wave(@hWave)
   text2 = "cat is hungry! press any key to feed it"
   'SLEEP
   SLEEP 
   isOut = FALSE
   text2 = ""
   loop UNTIL INKEY() = CHR(27)
  
END SUB


IF fbs_Init()=false then
  print "error: FBS_INIT() " & FBS_Get_PlugError()
  beep : sleep : end 1
end IF

'DIM SHARED AS long hWave
'DIM SHARED isOut AS boolean = FALSE
DIM SHARED fiori AS cat
file "main.bas"

Code: Select all

#INCLUDE ONCE "cat_obj.bi"
SCREEN 19


'fiori.make_sound("cat_sound.wav", 1)

fiori.animation("cat_sound.wav", 1)
it would be useful and a progress if i could learn to use the properties of the UDT and initialize then in the constructor and then use them inside the UDT subs and functions instead of counting on "dim shared ...." variables

ron77
ron77
Posts: 213
Joined: Feb 21, 2019 19:24

Re: an attempt to create a Tamagotchi cat program

Post by ron77 »

okay here is further progress this time with as little "DIM SHARED" vars as possible and with properties initialized in the constructor and used within the subs themselves...

this time with two counters for hunger and for pet-the-cat-time -

file "cat_obj.bi"

Code: Select all

#INCLUDE ONCE "fbsound_dynamic.bi"

DIM SHARED AS long hWave
'DIM SHARED isOut AS boolean = FALSE
'DIM SHARED text1 AS STRING
'DIM SHARED text2 AS STRING
'DIM SHARED AS INTEGER hunger
'hunger = INT(RND*101)
'ENUM poses
'   poses1
'   poses2
'   poses3
'END ENUM

TYPE cat
   AS STRING text1, text2, text3, text4
   isOut AS boolean
   AS INTEGER hunger, pet_count
   DECLARE SUB pet_cat()
   DECLARE SUB CP(row AS INTEGER, s AS STRING)
   DECLARE SUB display_screen(index AS INTEGER)
   DECLARE SUB make_sound(f AS STRING, t AS integer)
   DECLARE SUB animation(f AS STRING, t AS INTEGER)
   DECLARE SUB cat_hunger()
   DECLARE CONSTRUCTOR()
   DECLARE DESTRUCTOR()
   
END TYPE

CONSTRUCTOR cat
   this.isOut = FALSE
   this.hunger = INT(RND*101)
   THIS.text1 = ""
   this.text2 = ""
   this.text3 = ""
   this.text4 = ""
   this.pet_count = INT(RND*101)
END CONSTRUCTOR

DESTRUCTOR cat

END DESTRUCTOR

SUB cat.pet_cat()
   this.text3 = "cat pet time is: " & this.pet_count
   THIS.pet_count -= 1
   IF THIS.pet_count <= 50 THEN
      this.text4 = "press key 'p' to pet cat!"
   ELSEIF this.pet_count <= 25 THEN
      this.isOut = TRUE
      
   ENDIF
   IF INKEY = CHR(112) THEN THIS.pet_count = INT(RND*101)
END SUB

SUB cat.CP(row AS INTEGER, s AS STRING)
   LOCATE row, (100 - LEN(s)) / 2 : PRINT s
END SUB

SUB cat.display_screen(index AS integer)
   
   SELECT CASE index
      CASE 0:
         CLS
   CP 4, "^                        ^"
   CP 5, "( ) %%%%%%%%%%%%%%%%%%%  ( )"
   CP 6, "<| (( <|> ))  ||   ((  <|>  )) |>"
   CP 7, "_                              _"
   CP 8, "_                            _"
   CP 9, "_    >(::| * |::)<     _"
   CP 10, "        -------          "
   CP 11, "(  -----  )"
   CP 12, "\\---//"
   CP 13, "%%%"
   CP 34, text1
   CP 35, text2
   CP 32, text4
   CP 33, text3
      CASE 1:
         CLS
   CP 4, "^                        ^"
   CP 5, "( ) %%%%%%%%%%%%%%%%%%%  ( )"
   CP 6, "<| (( <I> ))  ||   ((  <I>  )) |>"
   CP 7, "_                              _"
   CP 8, "_                            _"
   CP 9, "_    >(::| * |::)<     _"
   CP 10, "                          "
   CP 11, "(  OOOO  )"
   CP 12, "\\   //"
   CP 13, "%%%"
   CP 34, text1
   CP 35, text2
   CP 32, text4
   CP 33, text3
      CASE 2:
         cls
   CP 4, "^                        ^"
   CP 5, "( ) %%%%%%%%%%%%%%%%%%%  ( )"
   CP 6, "<| (( <dOb> ))  ||   ((  <dOb>  )) |>"
   CP 7, "_                              _"
   CP 8, "_                            _"
   CP 9, "_    >(::| & |::)<     _"
   CP 10, "                          "
   CP 11, "(  ~~~~~  )"
   CP 12, "\\ ~~~ //"
   CP 13, "%%%"
   CP 34, text1
   CP 35, text2
   CP 32, text4
   CP 33, text3
   END SELECT
END SUB

'SUB CAT.ANIMATION(f AS STRING, t AS INTEGER)
'   start:
'   DIM i AS INTEGER = 0
'   make_sound(f, t)
'	hunger = INT(RND*101)
'   DO
'      IF i >= 3 THEN i = 0
'      DISPLAY_SCREEN(i)
'      SLEEP 500
'      i += 1
'      cat_hunger(hunger)
'         
'      ENDIF
'   LOOP UNTIL INKEY <> ""
'   fbs_Destroy_Wave(@hWave)
'   SLEEP 1000
'   GOTO start
'END SUB

SUB cat.cat_hunger()
   'start:
   'hunger = INT(RND*101)
   'DO
      this.text1 = "cat hunger is: " & hunger
      IF hunger < 27 THEN this.text2 = "cat is hungry! press any key to feed it"
      IF hunger >= 25 THEN
         hunger -= 1
      ELSEIF hunger <= 25 THEN
         'text2 = "cat is hungry! press any key to feed it"
         
         isOut = TRUE
         
      ENDIF
   'LOOP
   'GOTO start
   
END SUB



SUB cat.make_sound(f AS STRING, t AS INTEGER)
   'DIM AS Integer hWave
	fbs_Load_WAVFile(f , @hWave)
	fbs_Play_Wave(hWave , t)
	'SLEEP
  'While Inkey <> "":WEND
'	fbs_Destroy_Wave(@hWave)
END SUB

SUB CAT.ANIMATION(f AS STRING, t AS INTEGER)
   
   DO
   this.isOut = FALSE
   DIM i AS INTEGER = 0
   make_sound(f, t)
	this.hunger = INT(RND*101)
	this.pet_count = INT(RND*101)
   DO
      IF i >= 3 THEN i = 0
      DISPLAY_SCREEN(i)
      SLEEP 500
      i += 1
      cat_hunger()
         pet_cat()
         IF this.isOut = TRUE THEN EXIT DO
       
         
      
   LOOP UNTIL INKEY <> ""
   fbs_Destroy_Wave(@hWave)
   this.text2 = "cat is hungry! press any key to feed it"
   this.text4 = "press key 'p' to pet cat!"
   SLEEP 
   this.isOut = FALSE
   this.text2 = ""
   this.text4 = ""
   loop UNTIL INKEY() = CHR(27)
  
END SUB


IF fbs_Init()=false then
  print "error: FBS_INIT() " & FBS_Get_PlugError()
  beep : sleep : end 1
end IF

'DIM SHARED AS long hWave
'DIM SHARED isOut AS boolean = FALSE
DIM SHARED fiori AS cat


file "main.bas"

Code: Select all

#INCLUDE ONCE "cat_obj.bi"
SCREEN 19


'fiori.make_sound("cat_sound.wav", 1)

fiori.animation("cat_sound.wav", 1)
ron77
grindstone
Posts: 862
Joined: May 05, 2015 5:35
Location: Germany

Re: an attempt to create a Tamagotchi cat program

Post by grindstone »

ron77 wrote:...this took me hours :(
It took me two years to make my flight operator simulation playbable, so be patient.

You don't need a constructor to simply initialize variables:

Code: Select all

Type cat
	As String text1, text2, text3, text4
	As boolean isOut  = FALSE
	As Integer hunger = Int(Rnd*101), pet_count = Int(Rnd*101)
	Declare Sub pet_cat()
	Declare Sub CP(row As Integer, s As String)
	Declare Sub display_screen(index As Integer)
	Declare Sub make_sound(f As String, t As Integer)
	Declare Sub animation(f As String, t As Integer)
	Declare Sub cat_hunger()
End Type
String variables default to "".

And where can I get the fbsound_dynamic.bi?
ron77
Posts: 213
Joined: Feb 21, 2019 19:24

Re: an attempt to create a Tamagotchi cat program

Post by ron77 »

hello grindstone...

you can find fbsound1.1 library here : viewtopic.php?f=14&t=27272

as for the cat program i managed to add all what was suggested by imortis: here is the updated code -

file "cat_obj.bi"

Code: Select all

#INCLUDE ONCE "fbsound_dynamic.bi"

DIM SHARED AS long hWave
'DIM SHARED isOut AS boolean = FALSE
'DIM SHARED text1 AS STRING
'DIM SHARED text2 AS STRING
'DIM SHARED AS INTEGER hunger
'hunger = INT(RND*101)
'ENUM poses
'   poses1
'   poses2
'   poses3
'END ENUM

TYPE cat
   AS STRING text1, text2, text3, text4, text5, text6
   isOut AS boolean
   AS INTEGER hunger, pet_count, nap_count
   DECLARE SUB pet_cat()
   DECLARE SUB CP(row AS INTEGER, s AS STRING)
   DECLARE SUB display_screen(index AS INTEGER)
   DECLARE SUB make_sound(f AS STRING, t AS integer)
   DECLARE SUB animation(f AS STRING, t AS INTEGER)
   DECLARE SUB cat_hunger()
   DECLARE SUB nap_time(inx AS INTEGER)
   DECLARE SUB cat_napping()
   DECLARE CONSTRUCTOR()
   DECLARE DESTRUCTOR()
   
END TYPE

CONSTRUCTOR cat
   this.isOut = FALSE
   this.hunger = INT(RND*101)
   THIS.text1 = ""
   this.text2 = ""
   this.text3 = ""
   this.text4 = ""
   this.text5 = ""
   this.pet_count = INT(RND*201)
   this.nap_count = INT(RND*151)
END CONSTRUCTOR

DESTRUCTOR cat

END DESTRUCTOR

SUB cat.nap_time(inx AS INTEGER)
   SELECT CASE inx
      CASE 0:
         CLS
         CP 4, "------------"
         CP 5, "          / "
         CP 6, "         /  "
         CP 7, "        /   "
         CP 8, "       /    "
         CP 9, "      /     "
         CP 10, "     /      "
         CP 11, "    /       "
         CP 12, "   /        "
         CP 13, "  /         "
         CP 13, " /          "
         CP 14, "------------"
         CP 35, text5
      CASE 1:
         CLS
         CP 4, "%%%%%%%%%%%%"
         CP 5, "          % "
         CP 6, "         %  "
         CP 7, "        %   "
         CP 8, "       %    "
         CP 9, "      %     "
         CP 10, "     %      "
         CP 11, "    %       "
         CP 12, "   %        "
         CP 13, "  %         "
         CP 13, " %          "
         CP 14, "%%%%%%%%%%%%"
         CP 35, text5
      CASE 2:
         CLS
         CP 4, "zzzzzzzzzzzz"
         CP 5, "          z "
         CP 6, "         z  "
         CP 7, "        z   "
         CP 8, "       z    "
         CP 9, "      z     "
         CP 10, "     z      "
         CP 11, "    z       "
         CP 12, "   z        "
         CP 13, "  z         "
         CP 13, " z          "
         CP 14, "zzzzzzzzzzzz"
         CP 35, text5
   END SELECT
END SUB



SUB cat.pet_cat()
   this.text3 = "cat pet time is: " & this.pet_count
   THIS.pet_count -= 1
   IF THIS.pet_count <= 90 THEN
      this.text4 = "the cat need some petting press key 'p' to pet cat!"
   ELSEIF this.pet_count <= 25 THEN
      this.isOut = TRUE
      
   ENDIF
   IF INKEY = CHR(112) THEN 
      THIS.pet_count = INT(RND*101)
      this.text4 = ""
   ENDIF
   
END SUB

SUB cat.CP(row AS INTEGER, s AS STRING)
   LOCATE row, (100 - LEN(s)) / 2 : PRINT s
END SUB

SUB cat.display_screen(index AS integer)
   
   SELECT CASE index
      CASE 0:
         CLS
   CP 4, "^                        ^"
   CP 5, "( ) %%%%%%%%%%%%%%%%%%%  ( )"
   CP 6, "<| (( <|> ))  ||   ((  <|>  )) |>"
   CP 7, "_                              _"
   CP 8, "_                            _"
   CP 9, "_    >(::| * |::)<     _"
   CP 10, "        -------          "
   CP 11, "(  -----  )"
   CP 12, "\\---//"
   CP 13, "%%%"
   CP 34, text1
   CP 35, text2
   CP 32, text4
   CP 33, text3
   CP 31, text6
      CASE 1:
         CLS
   CP 4, "^                        ^"
   CP 5, "( ) %%%%%%%%%%%%%%%%%%%  ( )"
   CP 6, "<| (( <I> ))  ||   ((  <I>  )) |>"
   CP 7, "_                              _"
   CP 8, "_                            _"
   CP 9, "_    >(::| * |::)<     _"
   CP 10, "                          "
   CP 11, "(  OOOO  )"
   CP 12, "\\   //"
   CP 13, "%%%"
   CP 34, text1
   CP 35, text2
   CP 32, text4
   CP 33, text3
   CP 31, text6
      CASE 2:
         cls
   CP 4, "^                        ^"
   CP 5, "( ) %%%%%%%%%%%%%%%%%%%  ( )"
   CP 6, "<| (( <dOb> ))  ||   ((  <dOb>  )) |>"
   CP 7, "_                              _"
   CP 8, "_                            _"
   CP 9, "_    >(::| & |::)<     _"
   CP 10, "                          "
   CP 11, "(  ~~~~~  )"
   CP 12, "\\ ~~~ //"
   CP 13, "%%%"
   CP 34, text1
   CP 35, text2
   CP 32, text4
   CP 33, text3
   CP 31, text6
   END SELECT
END SUB

'SUB CAT.ANIMATION(f AS STRING, t AS INTEGER)
'   start:
'   DIM i AS INTEGER = 0
'   make_sound(f, t)
'	hunger = INT(RND*101)
'   DO
'      IF i >= 3 THEN i = 0
'      DISPLAY_SCREEN(i)
'      SLEEP 500
'      i += 1
'      cat_hunger(hunger)
'         
'      ENDIF
'   LOOP UNTIL INKEY <> ""
'   fbs_Destroy_Wave(@hWave)
'   SLEEP 1000
'   GOTO start
'END SUB
SUB cat.cat_napping()
   this.text6 = "cat napping counter is: " & this.nap_count
   'this.nap_count -= 1
   DIM x AS INTEGER = 0
   DIM xx AS INTEGER = 50
   'IF this.nap_count <= 50 THEN
          DO
             nap_time(x)
             this.text5 = "NAP TIME!"
             x += 1
             xx -= 1
             SLEEP 250
             IF x >= 3 THEN x = 0
          LOOP UNTIL xx <= 0
          
   'ENDIF
   'this.nap_count = INT(RND*151)
END SUB
SUB cat.cat_hunger()
   'start:
   'hunger = INT(RND*101)
   'DO
      this.text1 = "cat hunger is: " & hunger
      IF hunger < 27 THEN this.text2 = "cat is hungry! press any key to feed it"
      IF hunger >= 25 THEN
         hunger -= 1
      ELSEIF hunger <= 25 THEN
         'text2 = "cat is hungry! press any key to feed it"
         
         isOut = TRUE
         
      ENDIF
   'LOOP
   'GOTO start
   
END SUB



SUB cat.make_sound(f AS STRING, t AS INTEGER)
   'DIM AS Integer hWave
	fbs_Load_WAVFile(f , @hWave)
	fbs_Play_Wave(hWave , t)
	'SLEEP
  'While Inkey <> "":WEND
'	fbs_Destroy_Wave(@hWave)
END SUB

SUB CAT.ANIMATION(f AS STRING, t AS INTEGER)
   
   DO
   this.isOut = FALSE
   DIM i AS INTEGER = 0
   make_sound(f, t)
	this.hunger = INT(RND*101)
	this.pet_count = INT(RND*201)
	DIM x AS INTEGER = 0
   DIM xx AS INTEGER = 50
   DO
      IF THIS.nap_count > 50 THEN
      IF i >= 3 THEN i = 0
      DISPLAY_SCREEN(i)
      SLEEP 500
      i += 1
      cat_hunger()
         pet_cat()
         IF this.isOut = TRUE THEN EXIT DO
       this.text6 = "cat napping counter is: " & this.nap_count
       THIS.nap_count -= 1
      ELSEIF this.nap_count <= 50 THEN
          cat_napping()
          this.nap_count = INT(RND*151)
   ENDIF  
     
   LOOP UNTIL INKEY <> ""
   fbs_Destroy_Wave(@hWave)
   this.text2 = "cat is hungry! press any key to feed it"
   this.text4 = "press key 'p' to pet cat!"
   SLEEP 
   this.isOut = FALSE
   this.text2 = ""
   this.text4 = ""
   loop UNTIL INKEY() = CHR(27)
  
END SUB


IF fbs_Init()=false then
  print "error: FBS_INIT() " & FBS_Get_PlugError()
  beep : sleep : end 1
end IF

'DIM SHARED AS long hWave
'DIM SHARED isOut AS boolean = FALSE
DIM SHARED fiori AS cat
file "main.bas"

Code: Select all

#INCLUDE ONCE "cat_obj.bi"
SCREEN 19


'fiori.make_sound("cat_sound.wav", 1)

fiori.animation("cat_sound.wav", 1)
ron77
ron77
Posts: 213
Joined: Feb 21, 2019 19:24

Re: an attempt to create a Tamagotchi cat program

Post by ron77 »

well @grindstone... did you managed to use fbsound1.1 library?

ron77
grindstone
Posts: 862
Joined: May 05, 2015 5:35
Location: Germany

Re: an attempt to create a Tamagotchi cat program

Post by grindstone »

The program compiles and runs now, but there's no sound (I took another .wav file and named it "cat_sound.wav").
ron77
Posts: 213
Joined: Feb 21, 2019 19:24

Re: an attempt to create a Tamagotchi cat program

Post by ron77 »

hello everyone...

@grindstone - that is weird - did you made sure you putted the header bi files and the library files of fbsound1.1 inside the program folder? did you check the WAV file that it's okay?

any way i added anew feature to the program - if you do not feed the cat on time the cat dies and you start with a new cat - also made all counters on printed on same line - to pet the cat press key "p" - to feed it press key "f"...

here is the updated code:

file "cat_obj.bi"

Code: Select all

#INCLUDE ONCE "fbsound_dynamic.bi"

DIM SHARED AS long hWave
DIM SHARED AS STRING k
'DIM SHARED isOut AS boolean = FALSE
'DIM SHARED text1 AS STRING
'DIM SHARED text2 AS STRING
'DIM SHARED AS INTEGER hunger
'hunger = INT(RND*101)
'ENUM poses
'   poses1
'   poses2
'   poses3
'END ENUM

TYPE cat
   AS STRING text1, text2, text3, text4, text5, text6
   isOut AS boolean
   AS INTEGER hunger, pet_count, nap_count
   DECLARE SUB pet_cat()
   DECLARE SUB CP(row AS INTEGER, s AS STRING)
   DECLARE SUB display_screen(index AS INTEGER)
   DECLARE SUB make_sound(f AS STRING, t AS integer)
   DECLARE SUB animation(f AS STRING, t AS INTEGER)
   DECLARE SUB cat_hunger()
   DECLARE SUB nap_time(inx AS INTEGER)
   DECLARE SUB cat_napping()
   DECLARE CONSTRUCTOR()
   DECLARE DESTRUCTOR()
   
END TYPE

CONSTRUCTOR cat
   this.isOut = FALSE
   this.hunger = INT(RND*101)
   THIS.text1 = ""
   this.text2 = ""
   this.text3 = ""
   this.text4 = ""
   this.text5 = ""
   this.pet_count = INT(RND*201)
   this.nap_count = INT(RND*151)
END CONSTRUCTOR

DESTRUCTOR cat

END DESTRUCTOR

SUB cat.nap_time(inx AS INTEGER)
   SELECT CASE inx
      CASE 0:
         CLS
         CP 4, "------------"
         CP 5, "          / "
         CP 6, "         /  "
         CP 7, "        /   "
         CP 8, "       /    "
         CP 9, "      /     "
         CP 10, "     /      "
         CP 11, "    /       "
         CP 12, "   /        "
         CP 13, "  /         "
         CP 13, " /          "
         CP 14, "------------"
         CP 35, text5
      CASE 1:
         CLS
         CP 4, "%%%%%%%%%%%%"
         CP 5, "          % "
         CP 6, "         %  "
         CP 7, "        %   "
         CP 8, "       %    "
         CP 9, "      %     "
         CP 10, "     %      "
         CP 11, "    %       "
         CP 12, "   %        "
         CP 13, "  %         "
         CP 13, " %          "
         CP 14, "%%%%%%%%%%%%"
         CP 35, text5
      CASE 2:
         CLS
         CP 4, "zzzzzzzzzzzz"
         CP 5, "          z "
         CP 6, "         z  "
         CP 7, "        z   "
         CP 8, "       z    "
         CP 9, "      z     "
         CP 10, "     z      "
         CP 11, "    z       "
         CP 12, "   z        "
         CP 13, "  z         "
         CP 13, " z          "
         CP 14, "zzzzzzzzzzzz"
         CP 35, text5
   END SELECT
END SUB



SUB cat.pet_cat()
   'this.text3 = "cat pet time is: " & this.pet_count
   THIS.pet_count -= 1
   
   IF THIS.pet_count <= 50 THEN
      this.text4 = "the cat need some petting press key 'p' to pet cat!"
   'ELSEIF this.pet_count <= 25 THEN
   '   this.isOut = TRUE
   ELSE
      this.text4 = ""
      
   ENDIF
   IF k = CHR(112) THEN 
      THIS.pet_count = INT(RND*101)
      this.text4 = ""
   ENDIF
   
END SUB

SUB cat.CP(row AS INTEGER, s AS STRING)
   LOCATE row, (100 - LEN(s)) / 2 : PRINT s
END SUB

SUB cat.display_screen(index AS integer)
   
   SELECT CASE index
      CASE 0:
         CLS
   CP 4, "^                        ^"
   CP 5, "( ) %%%%%%%%%%%%%%%%%%%  ( )"
   CP 6, "<| (( <|> ))  ||   ((  <|>  )) |>"
   CP 7, "_                              _"
   CP 8, "_                            _"
   CP 9, "_    >(::| * |::)<     _"
   CP 10, "        -------          "
   CP 11, "(  -----  )"
   CP 12, "\\---//"
   CP 13, "%%%"
   CP 34, text1
   CP 35, text2
   CP 32, text4
   CP 33, text3
   CP 31, text6
      CASE 1:
         CLS
   CP 4, "^                        ^"
   CP 5, "( ) %%%%%%%%%%%%%%%%%%%  ( )"
   CP 6, "<| (( <I> ))  ||   ((  <I>  )) |>"
   CP 7, "_                              _"
   CP 8, "_                            _"
   CP 9, "_    >(::| * |::)<     _"
   CP 10, "                          "
   CP 11, "(  OOOO  )"
   CP 12, "\\   //"
   CP 13, "%%%"
   CP 34, text1
   CP 35, text2
   CP 32, text4
   CP 33, text3
   CP 31, text6
      CASE 2:
         cls
   CP 4, "^                        ^"
   CP 5, "( ) %%%%%%%%%%%%%%%%%%%  ( )"
   CP 6, "<| (( <dOb> ))  ||   ((  <dOb>  )) |>"
   CP 7, "_                              _"
   CP 8, "_                            _"
   CP 9, "_    >(::| & |::)<     _"
   CP 10, "                          "
   CP 11, "(  ~~~~~  )"
   CP 12, "\\ ~~~ //"
   CP 13, "%%%"
   CP 34, text1
   CP 35, text2
   CP 32, text4
   CP 33, text3
   CP 31, text6
   END SELECT
END SUB

'SUB CAT.ANIMATION(f AS STRING, t AS INTEGER)
'   start:
'   DIM i AS INTEGER = 0
'   make_sound(f, t)
'	hunger = INT(RND*101)
'   DO
'      IF i >= 3 THEN i = 0
'      DISPLAY_SCREEN(i)
'      SLEEP 500
'      i += 1
'      cat_hunger(hunger)
'         
'      ENDIF
'   LOOP UNTIL INKEY <> ""
'   fbs_Destroy_Wave(@hWave)
'   SLEEP 1000
'   GOTO start
'END SUB
SUB cat.cat_napping()
   'this.text2 = this.text2 & " cat napping counter is: " & this.nap_count
   'this.nap_count -= 1
   DIM x AS INTEGER = 0
   DIM xx AS INTEGER = 50
   'IF this.nap_count <= 50 THEN
          DO
             nap_time(x)
             this.text5 = "NAP TIME!"
             x += 1
             xx -= 1
             SLEEP 250
             IF x >= 3 THEN x = 0
          LOOP UNTIL xx <= 0
          
   'ENDIF
   'this.nap_count = INT(RND*151)
END SUB
SUB cat.cat_hunger()
   'start:
   'hunger = INT(RND*101)
   'DO
   
      'this.hunger -= 1
      'this.text2 = this.text2 & "cat hunger is: " & hunger
      IF this.hunger < 25 THEN
         this.text1 = "cat is hungry! press key 'f' to feed it"
      ELSE
         this.text1 = ""
      'IF this.hunger >= 25 THEN
      ENDIF
      IF this.hunger <= 0 THEN
         'text2 = "cat is hungry! press any key to feed it"
         
         isOut = TRUE
         
      ENDIF
      IF k = CHR(102) THEN
         this.hunger = INT(RND*101)
      ENDIF
   
   'LOOP
   'GOTO start
   
END SUB



SUB cat.make_sound(f AS STRING, t AS INTEGER)
   'DIM AS Integer hWave
	fbs_Load_WAVFile(f , @hWave)
	fbs_Play_Wave(hWave , t)
	'SLEEP
  'While Inkey <> "":WEND
'	fbs_Destroy_Wave(@hWave)
END SUB

SUB CAT.ANIMATION(f AS STRING, t AS INTEGER)
   
   DO
   this.isOut = FALSE
   DIM i AS INTEGER = 0
   make_sound(f, t)
	this.hunger = INT(RND*101)
	this.pet_count = INT(RND*201)
	DIM x AS INTEGER = 0
   DIM xx AS INTEGER = 50
   DO
      k = INKEY
      IF THIS.nap_count > 50 THEN
      IF i >= 3 THEN i = 0
      DISPLAY_SCREEN(i)
      SLEEP 500
      i += 1
      cat_hunger()
         pet_cat()
         IF this.isOut = TRUE THEN EXIT DO
       this.text2 = " cat hunger is: " & this.hunger & " cat napping counter is: " & this.nap_count & _
       " cat pet time is: " & this.pet_count
       THIS.nap_count -= 1
       this.hunger -= 1
      ELSEIF this.nap_count <= 50 THEN
          cat_napping()
          this.nap_count = INT(RND*151)
   ENDIF  
     
   LOOP UNTIL INKEY <> ""
   fbs_Destroy_Wave(@hWave)
   IF THIS.isOut = TRUE THEN
   CLS
   this.text1 = "CAT DIED FROM HUNGER - YOU DIDN'T FEED IT ON TIME!"
   this.text4 = "PRESS ANY KEY TO START OVER WITH A NEW CAT!"
   CP 31, THIS.text1
   CP 34, this.text4
   SLEEP 
   this.isOut = FALSE
   this.text1 = ""
   this.text4 = ""
   ENDIF
   loop UNTIL INKEY() = CHR(27)
  
END SUB


IF fbs_Init()=false then
  print "error: FBS_INIT() " & FBS_Get_PlugError()
  beep : sleep : end 1
end IF

'DIM SHARED AS long hWave
'DIM SHARED isOut AS boolean = FALSE
DIM SHARED fiori AS cat
file "main.bas"

Code: Select all

#INCLUDE ONCE "cat_obj.bi"
SCREEN 19


'fiori.make_sound("cat_sound.wav", 1)

fiori.animation("cat_sound.wav", 1)
ron77 :)
ron77
Posts: 213
Joined: Feb 21, 2019 19:24

Re: an attempt to create a Tamagotchi cat program

Post by ron77 »

hello all...

added cat_name private property and a getter and a setter for it :D

here is the updated code:

file "cat_obj.bi"

Code: Select all

#INCLUDE ONCE "fbsound_dynamic.bi"

DIM SHARED AS long hWave
DIM SHARED AS STRING k
'DIM SHARED isOut AS boolean = FALSE
'DIM SHARED text1 AS STRING
'DIM SHARED text2 AS STRING
'DIM SHARED AS INTEGER hunger
'hunger = INT(RND*101)
'ENUM poses
'   poses1
'   poses2
'   poses3
'END ENUM

TYPE cat
   PRIVATE:
   AS string cat_name
   PUBLIC:
   AS STRING text1, text2, text3, text4, text5, text6
   isOut AS boolean
   AS INTEGER hunger, pet_count, nap_count
   DECLARE PROPERTY cat_name1() AS STRING
   DECLARE PROPERTY cat_name1(BYVAL cat_name AS STRING)
   DECLARE SUB pet_cat()
   DECLARE SUB CP(row AS INTEGER, s AS STRING)
   DECLARE SUB display_screen(index AS INTEGER)
   DECLARE SUB make_sound(f AS STRING, t AS integer)
   DECLARE SUB animation(f AS STRING, t AS INTEGER)
   DECLARE SUB cat_hunger()
   DECLARE SUB nap_time(inx AS INTEGER)
   DECLARE SUB cat_napping()
   DECLARE CONSTRUCTOR()
   DECLARE DESTRUCTOR()
   
END TYPE

CONSTRUCTOR cat
   this.isOut = FALSE
   this.hunger = INT(RND*101)
   THIS.text1 = ""
   this.text2 = ""
   this.text3 = ""
   this.text4 = ""
   this.text5 = ""
   this.pet_count = INT(RND*201)
   this.nap_count = INT(RND*151)
   
END CONSTRUCTOR

DESTRUCTOR cat

END DESTRUCTOR

PROPERTY cat.cat_name1() AS String
   RETURN this.cat_name
END PROPERTY

PROPERTY cat.cat_name1(BYVAL cat_name AS STRING)
   this.cat_name = cat_name
END PROPERTY


SUB cat.nap_time(inx AS INTEGER)
   SELECT CASE inx
      CASE 0:
         CLS
         CP 4, "------------"
         CP 5, "          / "
         CP 6, "         /  "
         CP 7, "        /   "
         CP 8, "       /    "
         CP 9, "      /     "
         CP 10, "     /      "
         CP 11, "    /       "
         CP 12, "   /        "
         CP 13, "  /         "
         CP 13, " /          "
         CP 14, "------------"
         CP 35, text5
         CP 15, "cat " & cat_name1
      CASE 1:
         CLS
         CP 4, "%%%%%%%%%%%%"
         CP 5, "          % "
         CP 6, "         %  "
         CP 7, "        %   "
         CP 8, "       %    "
         CP 9, "      %     "
         CP 10, "     %      "
         CP 11, "    %       "
         CP 12, "   %        "
         CP 13, "  %         "
         CP 13, " %          "
         CP 14, "%%%%%%%%%%%%"
         CP 35, text5
         CP 15, "cat " & cat_name1
      CASE 2:
         CLS
         CP 4, "zzzzzzzzzzzz"
         CP 5, "          z "
         CP 6, "         z  "
         CP 7, "        z   "
         CP 8, "       z    "
         CP 9, "      z     "
         CP 10, "     z      "
         CP 11, "    z       "
         CP 12, "   z        "
         CP 13, "  z         "
         CP 13, " z          "
         CP 14, "zzzzzzzzzzzz"
         CP 35, text5
         CP 15, "cat " & cat_name1
   END SELECT
END SUB



SUB cat.pet_cat()
   'this.text3 = "cat pet time is: " & this.pet_count
   THIS.pet_count -= 1
   
   IF THIS.pet_count <= 50 THEN
      this.text4 = "the cat need some petting press key 'p' to pet cat!"
   'ELSEIF this.pet_count <= 25 THEN
   '   this.isOut = TRUE
   ELSE
      this.text4 = ""
      
   ENDIF
   IF k = CHR(112) THEN 
      THIS.pet_count = INT(RND*101)
      this.text4 = ""
   ENDIF
   
END SUB

SUB cat.CP(row AS INTEGER, s AS STRING)
   LOCATE row, (100 - LEN(s)) / 2 : PRINT s
END SUB

SUB cat.display_screen(index AS integer)
   
   SELECT CASE index
      CASE 0:
         CLS
   CP 15, "cat " & cat_name1
   CP 4, "^                        ^"
   CP 5, "( ) %%%%%%%%%%%%%%%%%%%  ( )"
   CP 6, "<| (( <|> ))  ||   ((  <|>  )) |>"
   CP 7, "_                              _"
   CP 8, "_                            _"
   CP 9, "_    >(::| * |::)<     _"
   CP 10, "        -------          "
   CP 11, "(  -----  )"
   CP 12, "\\---//"
   CP 13, "%%%"
   CP 34, text1
   CP 35, text2
   CP 32, text4
   CP 33, text3
   CP 31, text6
      CASE 1:
         CLS
   CP 15, "cat " & cat_name1
   CP 4, "^                        ^"
   CP 5, "( ) %%%%%%%%%%%%%%%%%%%  ( )"
   CP 6, "<| (( <I> ))  ||   ((  <I>  )) |>"
   CP 7, "_                              _"
   CP 8, "_                            _"
   CP 9, "_    >(::| * |::)<     _"
   CP 10, "                          "
   CP 11, "(  OOOO  )"
   CP 12, "\\   //"
   CP 13, "%%%"
   CP 34, text1
   CP 35, text2
   CP 32, text4
   CP 33, text3
   CP 31, text6
      CASE 2:
         cls
   CP 15, "cat " & cat_name1
   CP 4, "^                        ^"
   CP 5, "( ) %%%%%%%%%%%%%%%%%%%  ( )"
   CP 6, "<| (( <dOb> ))  ||   ((  <dOb>  )) |>"
   CP 7, "_                              _"
   CP 8, "_                            _"
   CP 9, "_    >(::| & |::)<     _"
   CP 10, "                          "
   CP 11, "(  ~~~~~  )"
   CP 12, "\\ ~~~ //"
   CP 13, "%%%"
   CP 34, text1
   CP 35, text2
   CP 32, text4
   CP 33, text3
   CP 31, text6
   END SELECT
END SUB

'SUB CAT.ANIMATION(f AS STRING, t AS INTEGER)
'   start:
'   DIM i AS INTEGER = 0
'   make_sound(f, t)
'	hunger = INT(RND*101)
'   DO
'      IF i >= 3 THEN i = 0
'      DISPLAY_SCREEN(i)
'      SLEEP 500
'      i += 1
'      cat_hunger(hunger)
'         
'      ENDIF
'   LOOP UNTIL INKEY <> ""
'   fbs_Destroy_Wave(@hWave)
'   SLEEP 1000
'   GOTO start
'END SUB
SUB cat.cat_napping()
   'this.text2 = this.text2 & " cat napping counter is: " & this.nap_count
   'this.nap_count -= 1
   DIM x AS INTEGER = 0
   DIM xx AS INTEGER = 50
   'IF this.nap_count <= 50 THEN
          DO
             nap_time(x)
             this.text5 = "NAP TIME!"
             x += 1
             xx -= 1
             SLEEP 250
             IF x >= 3 THEN x = 0
          LOOP UNTIL xx <= 0
          
   'ENDIF
   'this.nap_count = INT(RND*151)
END SUB
SUB cat.cat_hunger()
   'start:
   'hunger = INT(RND*101)
   'DO
   
      'this.hunger -= 1
      'this.text2 = this.text2 & "cat hunger is: " & hunger
      IF this.hunger < 25 THEN
         this.text1 = "cat is hungry! press key 'f' to feed it"
      ELSE
         this.text1 = ""
      'IF this.hunger >= 25 THEN
      ENDIF
      IF this.hunger <= 0 THEN
         'text2 = "cat is hungry! press any key to feed it"
         
         isOut = TRUE
         
      ENDIF
      IF k = CHR(102) THEN
         this.hunger = INT(RND*101)
      ENDIF
   
   'LOOP
   'GOTO start
   
END SUB



SUB cat.make_sound(f AS STRING, t AS INTEGER)
   'DIM AS Integer hWave
	fbs_Load_WAVFile(f , @hWave)
	fbs_Play_Wave(hWave , t)
	'SLEEP
  'While Inkey <> "":WEND
'	fbs_Destroy_Wave(@hWave)
END SUB

SUB CAT.ANIMATION(f AS STRING, t AS INTEGER)
   
   DO
      DIM catname AS STRING
      INPUT "enter cat name: ", catname
      cat_name1 = catname
      
   this.isOut = FALSE
   DIM i AS INTEGER = 0
   make_sound(f, t)
	this.hunger = INT(RND*101)
	this.pet_count = INT(RND*201)
	DIM x AS INTEGER = 0
   DIM xx AS INTEGER = 50
   DO
      k = INKEY
      IF THIS.nap_count > 50 THEN
      IF i >= 3 THEN i = 0
      DISPLAY_SCREEN(i)
      SLEEP 500
      i += 1
      cat_hunger()
         pet_cat()
         IF this.isOut = TRUE THEN EXIT DO
       this.text2 = " cat hunger is: " & this.hunger & " cat napping counter is: " & this.nap_count & _
       " cat pet time is: " & this.pet_count
       THIS.nap_count -= 1
       this.hunger -= 1
       IF k = CHR(27) THEN end
      ELSEIF this.nap_count <= 50 THEN
          cat_napping()
          this.nap_count = INT(RND*151)
   ENDIF  
     
   LOOP
   fbs_Destroy_Wave(@hWave)
   IF THIS.isOut = TRUE THEN
   CLS
   this.text1 = "CAT DIED FROM HUNGER - YOU DIDN'T FEED IT ON TIME!"
   this.text4 = "PRESS ANY KEY TO START OVER WITH A NEW CAT!"
   CP 31, THIS.text1
   CP 34, this.text4
   SLEEP 
   this.isOut = FALSE
   this.text1 = ""
   this.text4 = ""
   ENDIF
   loop UNTIL INKEY() = CHR(27)
  
END SUB


IF fbs_Init()=false then
  print "error: FBS_INIT() " & FBS_Get_PlugError()
  beep : sleep : end 1
end IF

'DIM SHARED AS long hWave
'DIM SHARED isOut AS boolean = FALSE
DIM SHARED fiori AS cat
file "main.bas"

Code: Select all

#INCLUDE ONCE "cat_obj.bi"
SCREEN 19


'fiori.make_sound("cat_sound.wav", 1)

fiori.animation("cat_sound.wav", 1)
ron77 :)
grindstone
Posts: 862
Joined: May 05, 2015 5:35
Location: Germany

Re: an attempt to create a Tamagotchi cat program

Post by grindstone »

All right now. With your latest code the sound plays.
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: an attempt to create a Tamagotchi cat program

Post by BasicCoder2 »

Unfortunately I still get
error: lib fsound-32 not loaded !
which flashes up in a command prompt window and closes,

In fbsound-1.0 > lib > win32 folder there is a libfbsound.a file file but it flags as "Unsupported archive file" when I attempt to unzip it with BreeZip
Post Reply