|
Hangman
Dec 11, 2018 14:30:04 GMT -6
Post by johnno56 on Dec 11, 2018 14:30:04 GMT -6
I know, "How lame", right?... lol
Anyway, sometime ago I through together a simple Hangman game using SDLBasic, and figured I would try my hand at converting it to RCBasic. Although the two languages are quite similar in a lot of respects there are quite a few differences to keep me on my toes... It's with these differences that I will probably end up needing help.
The SDL version works, the coding is NOT pretty, but works. It will be logical to assume that the RCBasic conversion will suffer the same unsightly fate... lol
I have completed the 'intro', loading of the assets, a sample word list and started on the 'game loop'. When I have a working prototype I will post it.
My first question is: What sound formats will work with both Linux AND Windows and which one will work the best? Ok. I know. Two questions... lol So my math skills are poor... lol
J
(I wasn't sure whether to post this in 'Projects' or 'Help'. Admin, if necessary, could you please move this post to the appropriate Forum? Thank you.)
|
|
|
Hangman
Dec 11, 2018 17:19:09 GMT -6
Post by n00b on Dec 11, 2018 17:19:09 GMT -6
Hey Johnno. To answer both of your questions, I would go with ".ogg" or ".mp3" for music and ".wav" for sound. And posting here is fine.
|
|
|
Hangman
Dec 11, 2018 17:30:00 GMT -6
Post by johnno56 on Dec 11, 2018 17:30:00 GMT -6
Thank you. Will do.
J
|
|
|
Hangman
Dec 12, 2018 0:17:33 GMT -6
Post by johnno56 on Dec 12, 2018 0:17:33 GMT -6
Ok. The conversion is done and so far it works on my Linux Desktop. I had to use the reference files many, many times. I do not know how to optimize the listing to make the listing look and perform better. I would appreciate any advice... even criticism as long as it's constructive... lol Here is the link... www.dropbox.com/s/35uaijbygp40pnc/hangman.zip?dl=0Just a note: I tried to use "select...end select" for key responses without much success. My original SDLBasic version used the mouse to guide a "gun" pointer when selecting letters. If someone could look into that as well? Use the keyboard for now... I cannot guarantee a "bug free" listing... lol Please let me know what you think? J (using 64 bit Linux version of RCBasic - 307)
|
|
|
Hangman
Dec 12, 2018 12:36:11 GMT -6
Post by n00b on Dec 12, 2018 12:36:11 GMT -6
When I get home tonight I will try it out. Did you manage to get sound working?
|
|
|
Hangman
Dec 12, 2018 18:25:13 GMT -6
Post by tbird on Dec 12, 2018 18:25:13 GMT -6
Good job! I love the background music, I got the first one in no time, second one hung me lol.
|
|
|
Hangman
Dec 13, 2018 5:37:02 GMT -6
Post by johnno56 on Dec 13, 2018 5:37:02 GMT -6
Thank you.
I figured that a "Western" themed game deserved a "Western" theme tune. "The Good, the Dad, and the Ugly" was the first tune I thought of... the second was "Blazing Saddles"... lol
There are still some tweaks that need doing... Found a minor glitch in the word selection... The program chose word number zero and the "dashes" became a "line" that trans versed the screen... Fixed THAT one... Yikes! Minor sound issues... The sound is fine but just needed to apply a "FadeOut" in certain spots.
I would still prefer the mouse to control events... The keyboard is fine but I miss the "Six shooter" pointer when choosing the letters...
Well, it's after 10:30pm here in Melbourne, and I'm quickly reaching my "use by date" for today. I think I might put the brain "on hold" and grab a coffee and allow an old movie to bore me to sleep... Goodnight.
J
|
|
|
Hangman
Dec 13, 2018 9:02:16 GMT -6
Post by tbird on Dec 13, 2018 9:02:16 GMT -6
I would use GetMouse() in your rendering loop, and just assign some globals mX,mY,mb1,mb2,mb3 (or whatever you want), also I would try and avoid so many nested loops, it would make it hard to render properly, I would just have one loop and when you register a key press or a mouse click send it off to a function to select the letter. I will be able to have a better look tonight. Also I apologize for not looking at it more closely earlier, I forgot you had concerns in an earlier post.
|
|
|
Hangman
Dec 13, 2018 9:05:38 GMT -6
Post by n00b on Dec 13, 2018 9:05:38 GMT -6
I got to try it out last night. I really liked the keyboard select personally but mouse controls for a shooter theme would probably be awesome as well. I started to look at the source code last night but I had only gotten 4 hours of sleep the night before so I just crashed. If you are not able to get it working by this weekend I will try to dive in and help you out.
|
|
|
Hangman
Dec 13, 2018 13:23:35 GMT -6
Post by johnno56 on Dec 13, 2018 13:23:35 GMT -6
I now have both keyboard and mouse control. SDLBasic uses a mouse command, MouseZone(), to determine a 'clickable' area. Through together a function to do roughly the same. Quick question. Does RCBasic have the ability to change the mouse pointer? If so, I can then use the "gun", as a pointer. No drama otherwise... When i get back home, in about an hour, I will re-post the listing. Wife and I always go for coffee on Friday mornings before she goes off to work...
J
|
|
|
Hangman
Dec 13, 2018 14:06:28 GMT -6
Post by johnno56 on Dec 13, 2018 14:06:28 GMT -6
As promised... The latest version. Updates are minor and mostly 'behind the scenes'. Can someone check my mousezone() function to make sure it's done right? J ps: "Listing" only.... Attachments:rchang.zip (2.63 KB)
|
|
|
Hangman
Dec 13, 2018 17:23:42 GMT -6
Post by n00b on Dec 13, 2018 17:23:42 GMT -6
Johnno, if you want to make a custom mouse pointer you can just use HideMouse() and draw your pointer image at mouseX, mouseY. I will try out your new version when I get home.
|
|
|
Hangman
Dec 13, 2018 18:46:47 GMT -6
Post by johnno56 on Dec 13, 2018 18:46:47 GMT -6
Ah, I figured you may say that... I had already attempted the hidemouse() and drawing the gun at mousex, mousey, but because there is no cls happening during the letter selection, the gun left "trails" on the screen... Kind of makes it hard to use... lol
For the moment, I think I will return to keyboard, until sorted out. Just a point with mousezone... This only works if the window and canvas are 'windowed'... Changing the display to 'full screen' renders the function a bit useless. Yet another reason to stick with the keyboard... lol
J
|
|
|
Hangman
Dec 14, 2018 0:06:25 GMT -6
Post by tbird on Dec 14, 2018 0:06:25 GMT -6
Hey johnno, I whipped this up quick to give an example of what I meant, it solves a couple issues for you I believe.
'Initialize the screen scr_width = 1024 scr_height = 768 main_window = 1 main_canvas = 1
WindowOpen(main_window, "Entity Creator", 0, 0, scr_width, scr_height, 1) Window(main_window)
CanvasOpen(main_canvas, scr_width, scr_height, 0, 0, scr_width, scr_height, 1) Canvas(main_canvas)
DIM assetDir$ DIM workDir$ DIM rubicFont$
If OS = "WINDOWS" Then assetDir$ = Dir$ + "\\assets\\" workDir$ = Dir$ Else assetDir$ = Dir$ + "/assets/" workDir$ = Dir$ End If
'Load Font LoadFont(1, assetDir$ + "rubicmono.ttf", 30) LoadFont(2, assetDir$ + "rubicmono.ttf", 60) Font(1) SetColor(RGB(100,50,200))
'Image loading DIM imgCursor imgCursor = 50
LoadImage(imgCursor, assetDir$ + "gun.png")
'Sound loading DIM gunSound gunSound = 1
LoadSound(gunSound, assetDir$ + "shot.wav")
'Simple mouse over image function Function MouseOverImage(img, x, y) w = 0 h = 0 GetImageSize(img, w, h) mX = MouseX mY = MouseY
If mX > x And mX < x + w And mY > y And mY < y + h Then Return True Else Return False End If End Function
'Setup array for letters DIM letters$[26] DIM imgLetters[26] For i = 0 To 26 - 1 imgLetters[i] = i Next DIM lettersX[26] DIM lettersY[26]
letters$[0] = "a" letters$[1] = "b" letters$[2] = "c" letters$[3] = "d" letters$[4] = "e" letters$[5] = "f" letters$[6] = "g" letters$[7] = "h" letters$[8] = "i" letters$[9] = "j" letters$[10] = "k" letters$[11] = "l" letters$[12] = "m" letters$[13] = "n" letters$[14] = "o" letters$[15] = "p" letters$[16] = "q" letters$[17] = "r" letters$[18] = "s" letters$[19] = "t" letters$[20] = "u" letters$[21] = "v" letters$[22] = "w" letters$[23] = "x" letters$[24] = "y" letters$[25] = "z"
DIM modX modX = 40
'Create images of the alphabet For i = 0 To 26 - 1 RenderText(imgLetters[i], letters$[i]) lettersX[i] = modX * i lettersY[i] = 500 Next
DIM letterToShow$ DIM showLargeLetter
'Draw the selected letter Function DrawHitLetter(letter$) Font(2) DrawText(letter$, 380, 100) End Function
'byRef for get mouse function DIM mX DIM mY DIM mB1 DIM mB2 DIM mB3
'Timer for mouse buttons DIM buttonTimer buttonTimer = Timer() DIM buttonTimeDiff buttonTimeDiff = 150
HideMouse() While NOT Key(K_ESCAPE) ClearCanvas() GetMouse(mX, mY, mB1, mB2, mB3) 'Draw our alphabet For i = 0 To 26 - 1 DrawImage(imgLetters[i], lettersX[i], lettersY[i]) Next If showLargeLetter = True Then DrawHitLetter(letterToShow$) End If 'If we the timer is good, and mouse button 1 is hit If Timer() - buttonTimer > buttonTimeDiff And mB1 Then For i = 0 To 26 - 1 If MouseOverImage(imgLetters[i], lettersX[i], lettersY[i]) Then PlaySound(gunSound, 1, 0) letterToShow$ = letters$[i] showLargeLetter = True End If Next End If 'Right click to remove the large letter If mB3 = 1 Then showLargeLetter = False End If modX = 1 DrawImage(imgCursor, mX, mY) Update() Wend I hope this helps out, I will have more time tomorrow night!
|
|
|
Hangman
Dec 14, 2018 3:40:53 GMT -6
Post by johnno56 on Dec 14, 2018 3:40:53 GMT -6
Cool. Your example works better than mine as I stated earlier, a cls (or ClearCanvas), was not included whilst the letters were being selected. Had not anticipated the gunshot... Nice effect...
I would need to rethink how the overall display is produced so as to achieve the same effect as you did. Many thanks for your efforts and your willingness to help. Much appreciated...
J
|
|