Weekly Qbasic and Qb64 Lesson Topics
October 12, 2024, 07:18:34 am
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Want to see a specific Tutorial? ASK!
 
  Home Help Search Arcade Links Staff List Login Register  

My Experiment

Pages: [1]
  Print  
Author Topic: My Experiment  (Read 1658 times)
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« on: February 28, 2011, 11:44:37 pm »

This was a experiment am doing useing the Demo code  posted,

Code:
'edited, I cut all the previous and am posting this, I think I got it playing the
'music, at least on my computer it dose.

DEFLNG A-Z
DIM Rpac%(8)
DIM Lpac%(8)
DIM Upac%(8)
DIM Dpac%(8)
DIM Hpac%(2) 'R + L y axis figures
DIM VUpac%(2) 'U  y axis figures
DIM VDpac%(2) 'D  y axis figures
Sprite& = _LOADIMAGE("Pacy001.bmp", 32)
Video& = _NEWIMAGE(640, 480, 32)
SCREEN Video&
GOSUB Setup
cycle = 0: px = 100: py = 100: Dir = 2
'//these are the text lines I added
LOCATE 20, 1: PRINT " Hello World, now just give me some dots to eat"
LOCATE 25, 40: PRINT "eat this"
LOCATE 28, 20: PRINT " EAT this too...................................."

'-----------------------------------------------------code for sound
volume = 1 '                                               full volume
gamestart = False '                                        no game yet
intromusic = _SNDOPEN("pacman2.mid", "VOL") '           open intro music
_SNDVOL intromusic, volume '                               set music volume
_SNDLOOP intromusic '
PRINT "This is my Music"

DO
    _LIMIT 30
    cycle = cycle + 1: IF cycle >= 31 THEN cycle = 1
    GOSUB Getframe
    GOSUB Getkey
    GOSUB Checkbounds
    'CLS   'in order to show the above text, needed to rem this
    SELECT CASE frame
        CASE 1
            IF Dir = 1 THEN _PUTIMAGE (px, py)-(px + 27, py + 27), Sprite&, Video&, (Rpac%(0), VUpac%(0))-(Rpac%(1), VUpac%(1))
            IF Dir = 2 THEN _PUTIMAGE (px, py)-(px + 27, py + 27), Sprite&, Video&, (Rpac%(0), Hpac%(0))-(Rpac%(1), Hpac%(1))
            IF Dir = 3 THEN _PUTIMAGE (px, py)-(px + 27, py + 27), Sprite&, Video&, (Rpac%(0), VUpac%(1))-(Rpac%(1), VUpac%(0))
            IF Dir = 4 THEN _PUTIMAGE (px, py)-(px + 27, py + 27), Sprite&, Video&, (Rpac%(1), Hpac%(0))-(Rpac%(0), Hpac%(1))
        CASE 2
            IF Dir = 1 THEN _PUTIMAGE (px, py)-(px + 27, py + 27), Sprite&, Video&, (Rpac%(2), VUpac%(0))-(Rpac%(3), VUpac%(1))
            IF Dir = 2 THEN _PUTIMAGE (px, py)-(px + 27, py + 27), Sprite&, Video&, (Rpac%(2), Hpac%(0))-(Rpac%(3), Hpac%(1))
            IF Dir = 3 THEN _PUTIMAGE (px, py)-(px + 27, py + 27), Sprite&, Video&, (Rpac%(2), VUpac%(1))-(Rpac%(3), VUpac%(0))
            IF Dir = 4 THEN _PUTIMAGE (px, py)-(px + 27, py + 27), Sprite&, Video&, (Rpac%(3), Hpac%(0))-(Rpac%(2), Hpac%(1))

        CASE 3
            IF Dir = 1 THEN _PUTIMAGE (px, py)-(px + 27, py + 27), Sprite&, Video&, (Rpac%(4), VUpac%(0))-(Rpac%(5), VUpac%(1))
            IF Dir = 2 THEN _PUTIMAGE (px, py)-(px + 27, py + 27), Sprite&, Video&, (Rpac%(4), Hpac%(0))-(Rpac%(5), Hpac%(1))
            IF Dir = 3 THEN _PUTIMAGE (px, py)-(px + 27, py + 27), Sprite&, Video&, (Rpac%(4), VUpac%(1))-(Rpac%(5), VUpac%(0))
            IF Dir = 4 THEN _PUTIMAGE (px, py)-(px + 27, py + 27), Sprite&, Video&, (Rpac%(5), Hpac%(0))-(Rpac%(4), Hpac%(1))
        CASE 4
            IF Dir = 1 THEN _PUTIMAGE (px, py)-(px + 27, py + 27), Sprite&, Video&, (Rpac%(6), VUpac%(0))-(Rpac%(7), VUpac%(1))
            IF Dir = 2 THEN _PUTIMAGE (px, py)-(px + 27, py + 27), Sprite&, Video&, (Rpac%(6), Hpac%(0))-(Rpac%(7), Hpac%(1))
            IF Dir = 3 THEN _PUTIMAGE (px, py)-(px + 27, py + 27), Sprite&, Video&, (Rpac%(6), VUpac%(1))-(Rpac%(7), VUpac%(0))
            IF Dir = 4 THEN _PUTIMAGE (px, py)-(px + 27, py + 27), Sprite&, Video&, (Rpac%(7), Hpac%(0))-(Rpac%(6), Hpac%(1))
    END SELECT
    _DISPLAY
LOOP UNTIL _KEYDOWN(27)

SCREEN 0
_FREEIMAGE Video&
_FREEIMAGE Sprite&
SLEEP
SYSTEM
'---------------------- SUBS -----------------------------
Checkbounds:
IF px >= 610 THEN px = 610
IF px <= 2 THEN px = 2
IF py >= 450 THEN py = 450
IF py <= 2 THEN py = 2
RETURN

Getkey:
'----------- these 2 lines I added, CG gave me the code----------
ox = x1
oy = y1
'---------------------------------------------------------
'the key to directions U=1  E =2  S =3  W =4
IF _KEYDOWN(18432) THEN '<---- up arrow key
    Dir = 1: py = py - 1
END IF
IF _KEYDOWN(19712) THEN '<---- right arrow key
    Dir = 2: px = px + 1

END IF
IF _KEYDOWN(20480) THEN '<---- down arrow key
    Dir = 3: py = py + 1
END IF

IF _KEYDOWN(19200) THEN '<---- left arrow key
    Dir = 4: px = px - 1
END IF
RETURN

Getframe:
'--------------and I had to add this, based on what CG gave me
LINE (ox, oy)-(ox + 94, oy + 94), 0, BF
'-----------------------------------------------
SELECT CASE cycle
    CASE 5, 10, 15, 20, 25, 30
        frame = frame + 1: IF frame >= 5 THEN frame = 1
END SELECT
RETURN

Setup:
'right facing pac man x axis
Rpac%(0) = 0
Rpac%(1) = 55
Rpac%(2) = 57
Rpac%(3) = 112
Rpac%(4) = 114
Rpac%(5) = 169
Rpac%(6) = 171
Rpac%(7) = 226
'left facing pac man x axis
Lpac%(0) = 55
Lpac%(1) = 0
Lpac%(2) = 112
Lpac%(3) = 57
Lpac%(4) = 169
Lpac%(5) = 114
Lpac%(6) = 226
Lpac%(7) = 171
'up facing pac man x axis
Upac%(0) = 0
Upac%(1) = 55
Upac%(2) = 57
Upac%(3) = 112
Upac%(4) = 114
Upac%(5) = 169
Upac%(6) = 171
Upac%(7) = 226
'down facing pac man x axis
Dpac%(0) = 0
Dpac%(1) = 55
Dpac%(2) = 57
Dpac%(3) = 112
Dpac%(4) = 114
Dpac%(5) = 169
Dpac%(6) = 171
Dpac%(7) = 226
'right + left facing pac y axis's
Hpac%(0) = 0
Hpac%(1) = 55
'down  facing pac y axis's
VDpac%(0) = 57
VDpac%(1) = 112
'up  facing pac y axis's
VUpac%(0) = 112
VUpac%(1) = 57
RETURN

For the sprite sheet that was copied
http://dl.dropbox.com/u/10291175/Pacy001.bmp
Note: here is the midi :

http://dl.dropbox.com/u/15387474/PacMan2.rar
These are 3 more midis, just change the filename, in the .BAS
and use whichever you like.

http://dl.dropbox.com/u/15387474/midis.rar
From Garry
Edited: It looks and sounds like I got the sound to work,....and you draw something as it runs! At least on my computer, hope fully this works on yours to!...from Garr
« Last Edit: September 07, 2011, 11:28:03 pm by GarrisonRicketson » Report Spam   Logged

Share on Facebook Share on Twitter

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #1 on: March 06, 2011, 05:53:09 pm »

Allthough you did post some demos useing midi or .wav
I am wondering if you you can give me an example, of makeing this .mid
play in the previous code, as a continues loop,background sound, for the time the program is runinng,

Edit: Since the first was not very good any way, I am just going to put in the better one, and zipped,
http://dl.dropbox.com/u/15387474/PacMan2.rar
 I just want to see how it is loaded,...
useing "My experiment", as the guini pig, I think as admin, you can actually modify.
the experiment code, if not, you will need to post a new sample,...just to say if you can and want to just modify, the code I posted.
 I need this, so as I work on the music, I can load it and see/as well as hear,
how it fits with the sprite movemnts,...
 Also, note in this midi, there is kind of a long space,of silence,...don't worry about that, it will get filled, or removed.
 Thanks from Garry
P.S . I also did a test, on modifying, and you can modify, these posts too.,
we just need to be careful, to advise each other, if and when something is edited.

« Last Edit: September 07, 2011, 11:28:45 pm by GarrisonRicketson » Report Spam   Logged

none
Guest
« Reply #2 on: March 06, 2011, 09:04:21 pm »


    This works but causes a windows fault near the end of the "clip".
Code:
REM
DEFLNG A-Z
'assumes the sound is in the current directory
mid1& = _SNDOPEN("pacman2.mid", "vol")
_SNDVOL mid1&, 0.7

DO
  IF NOT _SNDPLAYING(mid1&) THEN
    _SNDPLAY mid1&
  END IF
  IF _KEYDOWN(27) THEN
    EXIT DO
  END IF
LOOP
_SNDSTOP mid1&
_SNDCLOSE mid1&
SLEEP
SYSTEM
   
« Last Edit: September 07, 2011, 11:29:36 pm by GarrisonRicketson » Report Spam   Logged
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #3 on: March 06, 2011, 09:24:26 pm »

I didn't get any error, it ran fine,....
but here is a different one
http://dl.dropbox.com/u/15387474/PacMan2.rar
This is the pacman2.mid, above.
Quote
  Id suggest you eother try to download it again or re-compose it as something is wrong with it. Try converting it to OGG may help. 
What is OGG ?, is that , the format, IE; .mid, .wav , .OGG ,there are many,...
It may be because of the balnk space in it, the 2nd one is better (pacman2.mid)
From Garry
« Last Edit: March 06, 2011, 10:17:10 pm by GarrisonRicketson » Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #4 on: March 06, 2011, 10:38:33 pm »

Ok I replaced all, of them with the paman2.rar , which I also downloaded, and put in my qb64 dir, to check, the download,...The qb64 program, is running and playing it as I type this right now, note I also made the filename adjustment in your post, of the code....to demonstrate, Don't worry I won't ever edit your code, normally, that you have posted,...but in reverse, when I post some code, that is not quite right, if you want you can just modify it on line,...no need to copy and paste it, and the re, copy and paste to a new post,..
 Do I make sense, hope so.....This experiment thread, could turn out pretty useful,...
from Garry
Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #5 on: March 07, 2011, 12:51:56 am »

I posted new code in my original post, the sound seems to work,...
from Garry
Note: At lunch time, I use a computer at the internet cafe, downloaded qb64, and ran this, "my Experiment", ...the sound played ok,...and it ran ok,..
The only trouble I had is cause these computers, are practically junk, they see alot of abuse, some kids had disabled the sound, on the computer, but once I fixed that, it played fine........
from Garry
« Last Edit: March 07, 2011, 01:38:47 pm by GarrisonRicketson » Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #6 on: March 07, 2011, 07:12:16 pm »


  And on the zipping sound files, it never occured to me, I've noticed the same
occurs for me when it is a image, I will see the image, and it downloads,..
 So I did it play ok, after you downloaded it ? I am not so sure I like it that much, but for testing it is ok.
From Garry
Here are 3 more midis to try:

http://dl.dropbox.com/u/15387474/midis.rar
« Last Edit: September 07, 2011, 11:32:18 pm by GarrisonRicketson » Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #7 on: March 10, 2011, 05:47:00 pm »

OK, at least for now, I need to find or make a couple, 1. the sound, that goes
with when the dots are eaten,...2. a sound for when a ghost, attacks, 3.the sound if he (the ghost ) kills pacman (the player).......When a level is completed, and a new level started,? perhaps a new theme song ?
 After reading your post in the original thread, where the "good" code is,
On the ghosts,..16, 4 groups of 4 ....so then they should be 20 x 20, ?
(I guess Jim should have posted the samples here,but he did not realize that)
 I may be confuseing things, by bringing this up here,.....Because I actually need to look at your post again, and can't from here,....I will modify this message shortly, and or another, thread.
from Garry
----------------------------------------------------------------
« Last Edit: September 07, 2011, 11:34:19 pm by GarrisonRicketson » Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #8 on: March 17, 2011, 08:04:36 pm »

These are the most recent ghosts,...same as the ones I have on the drop box link.
 But with photo bucket:
NEW Ghosts
This is the sprite sheet, below:



This is the Gif, below:


Mostly just to see,..if I got this worked out right.
From Garry
Report Spam   Logged

Dustie Bear
Full Member
***
Posts: 115


« Reply #9 on: March 17, 2011, 09:10:20 pm »



Looks Ghostly to me.  Grin

I never seen a ghost before so hes the
cutest one Ive ever seen.

Dustie
Report Spam   Logged
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #10 on: March 19, 2011, 11:23:36 pm »

I was experimenting again, with _putimage,...useing this,
Code:
       REM GHOST
DEFLNG A-Z

SCREEN _NEWIMAGE(640, 480, 32)

WorkPage& = _LOADIMAGE("NEWGHOST_blu1.png")

_DEST 0

DO
    FOR x = 0 TO 261 STEP 67
        _PUTIMAGE (100, 100)-(220, 190), WorkPage&, 0, (x, 0)-(x + 67, 67) '219,189
        _DELAY .08


    NEXT x

LOOP WHILE INKEY$ = ""
SLEEP
SYSTEM
     
   
Here is the sprite sheet, I know,  it is not the conventional standered, but I found it interesting to see I could load and view it useing _putimage   
Any way guess thats about it.
from Garry
« Last Edit: March 20, 2011, 08:56:05 am by GarrisonRicketson » Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #11 on: March 28, 2011, 09:01:58 am »

OK,  I have to run too, just to acknowlege the reply,...
later
from Garry
Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #12 on: September 09, 2011, 12:11:28 am »

This is the PacMan I plan to use,...it is original,...

From Garry
« Last Edit: September 20, 2011, 12:33:09 am by GarrisonRicketson » Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #13 on: September 09, 2011, 12:37:11 am »

So as you see in this thread, I have 1 ghost, and 1 pacman,..now How do we make that into a very simple pac man game,. With completely original images,..
useng qb64 ? ---Originaly that was going to be what this forum was about .and then I got side tracked,...all sorts of BS,etc....
 So anyway, from here on I, or we if anyone wants to help, am going to try to work it out and finish, just a real simple version, 1 pacman, 1 ghost, and a maze, or even just the ghost moveing around randomly,..and the Pacman trys to catch and eat it.  Then if there still is interest, we can try to go onto something more.
from Garry
Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #14 on: September 20, 2011, 12:40:16 am »

Well I just stumbled onto this,..
    TRONPACMAN On qb64.net, by Theopage, in this thread, is the developement, and completion of a
pacman based game, with tron,..it is pretty neat, different from what I have in mind,but could be very useful in learning, too,...Also at the bottom of the thread is a downloadble tronpacman.zip,...that you can use on your computer to play it,...
 enjoy!
From Garry
Report Spam   Logged


Pages: [1]
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum


Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy