Web Based Adventure (WBA)

Tips, techniques and tutorials about creation tools.

Re: Web Based Adventure (WBA)

Postby sylakone2 » Wed, 15Jun10 16:25

tlaero wrote:I thought the point of Spartan was that it was supposed to be more web standards compliant so that web developers wouldn't need to do special cases anymore. Troublesome that it's not working with existing stuff, but hopefully it's just because it's not released yet. Chrome is getting bloated, but an incompatible browser isn't going to win over any users.

Hey Syl, do recent Adventure Creator games like BEW and LwK2.0 work in Spartan?

Tlaero


Hey Ms Tlaero
Actually BEW seems to work fine with spartan.
So it looks like your wonderful adventure creator is good to go for future generations of browsers :)

Cheers

Sy
Cheers Sy
User avatar
sylakone2
lagoon predator
 
Posts: 224
Joined: Mon, 12Jan09 13:08
Location: Australia, SA
sex: Masculine

Re: Web Based Adventure (WBA)

Postby tlaero » Thu, 15Jun11 05:23

Thanks for checking, Syl.

Tlaero
User avatar
tlaero
Lady Tlaero, games and coding expert
 
Posts: 1829
Joined: Thu, 09Jun04 23:00
sex: Female

Re: Web Based Adventure (WBA)

Postby sylakone2 » Sun, 15Jun14 03:56

tlaero wrote:Thanks for checking, Syl.

Tlaero


You are welcome.

Cheers

Sy
Cheers Sy
User avatar
sylakone2
lagoon predator
 
Posts: 224
Joined: Mon, 12Jan09 13:08
Location: Australia, SA
sex: Masculine

Re: Web Based Adventure (WBA)

Postby kexter » Tue, 15Jun16 00:20

sylakone2 wrote:Also I was looking to see if it is possible to add some songs to the game I am making is that possible?

To Sy and anyone else looking to add music to their WBA games. I've made and "extension" to WBA that makes it possible. You simply need to add the following code to your custom.js and you're ready to go:
Code: Select all
(function () {
  'use strict';
  window.kexPlayBGM = function (srcSet, doLoop, snapChange) {
    /// <summary>Starts playing the specified music file.</summary>
    /// <param name="srcSet" type="Array" elementType="String">An array containing all the alternative sources for the audio.</param>
    /// <param name="doLoop" type="Boolean">Set to true if you want the music to loop. Defaults to true.</param>
    /// <param name="snapChange" type="Boolean">Do not fade between songs. Defaults to false.</param>
    var i, ext, audio, source, initialVolume;
    // Special case for cross-fading two songs.
    if (srcSet === true) {
      audio = document.getElementById('kex-bgm');
      if (!!audio) {
        if (audio.volume < 0.95) {
          audio.volume = audio.volume + 0.05;
          setTimeout(function () {
            kexPlayBGM(true);
          }, 100);
        } else {
          audio.volume = 1.0;
        }
      }
      return;
    }
    // Normal case for starting the playback of a song.
    if (typeof srcSet === 'string') {
      srcSet = [srcSet];
    }
    doLoop = typeof doLoop === 'undefined' ? true : doLoop;
    snapChange = typeof snapChange === 'undefined' ? false : snapChange;
    initialVolume = 1.0;
    audio = document.getElementById('kex-bgm');
    if (!!audio && !snapChange) {
      audio.id = 'kex-bgm-2';
      kexStopBGM(true, 'kex-bgm-2');
      initialVolume = 0.0;
    }
    kexStopBGM(false);
    audio = document.createElement('audio');
    audio.id = 'kex-bgm';
    audio.preload = 'auto';
    audio.autoplay = true;
    audio.loop = doLoop;
    audio.volume = initialVolume;
    for (i = 0; i < srcSet.length; i++) {
      ext = srcSet[i].split('.').pop().toLowerCase();
      ext = ext === 'mp3' ? 'audio/mpeg' : (ext === 'ogg' ? 'audio/ogg' : 'audio/wav');
      source = document.createElement('source');
      source.src = srcSet[i];
      source.type = ext;
      audio.appendChild(source);
    }
    document.body.appendChild(audio);
    if (initialVolume < 1) {
      kexPlayBGM(true);
    }
  };
  window.kexStopBGM = function (doFade, elementId) {
    /// <summary>Stops the currently playing music.</summary>
    /// <param name="doFade" type="Boolean">Stop the music with a fade-out effect. Defaults to true.</param>
    /// <param name="elementId" type="String">The id of the audio element to be stopped. Defaults to the default BGM element.</param>
    var audio;
    doFade = typeof doFade === 'undefined' ? true : doFade;
    elementId = typeof elementId === 'undefined' ? 'kex-bgm' : elementId;
    audio = document.getElementById(elementId);
    if (!!audio) {
      if (audio.volume > 0.05 && doFade) {
        audio.volume = audio.volume - 0.05;
        setTimeout(function() {
          kexStopBGM(doFade, elementId);
        }, 100);
      } else {
        audio.parentNode.removeChild(audio);
      }
    }
  }
}());
This will add two new functions, kexPlayBGM() and kexStopBGM().

Here are some usage examples:

You can start playing a music file by adding the following to the onload event of a page (or to one of the onclick events):
Code: Select all
kexPlayBGM('music/example.mp3')
where 'music/example.mp3' is the file you want to play. You must use single quotes.

By default the specified song will be looped, if you do not want it to loop, use the following instead:
Code: Select all
kexPlayBGM('music/example.mp3', false)


To stop the background music, simply add the following to a relevant onload or onclick event:
Code: Select all
kexStopBGM()


By default, kexStopBGM() will fade out the song, if you want playback to be immediately stopped, use the following:
Code: Select all
kexStopBGM(false)


Note that calling kexPlayBGM('music/example2.mp3') while another song is already playing, will fade between the two songs. If you do not want to fade between songs, use the following:
Code: Select all
kexPlayBGM('music/example2.mp3', true, true)


Also note that you can specify alternate files in different audio formats, like so:
Code: Select all
kexPlayBGM(['music/example.mp3', 'music/example.ogg'])
Since all modern browsers seem to have support for mp3 files, this is no longer necessary but in case you want to support browsers which don't have mp3-support, you can do it this way.

[mod: spoiler only added here to help reduce page length]
@kextercius
User avatar
kexter
Moderator
 
Posts: 214
Joined: Sun, 13Dec29 11:01
sex: Masculine

Re: Web Based Adventure (WBA)

Postby sylakone2 » Tue, 15Jun16 15:12

Awesome Kex

Thanks heaps for your brilliant coding skills.

Cheers

Sy
Cheers Sy
User avatar
sylakone2
lagoon predator
 
Posts: 224
Joined: Mon, 12Jan09 13:08
Location: Australia, SA
sex: Masculine

Re: Web Based Adventure (WBA)

Postby SoulMate » Thu, 15Jun18 21:09

Hey Kex,
Thx for the fixes and support to other users. I really appreaciate it.

Currently i'm working on a full rewrite of the build module. It looks exactly the same, but is written in AngularJS. This allow me (and eventually other developers - kex?) to scale and develop quicker in the future. Most of the work is done, but there are still a few missing features that were available in the previous version. When all features are ready i'll release the version.

The debug and play will stay exactly the same.

I Also updated the overview module by using the js vis plugin to visualize the game flow better:
Image

@kex, if your interested to help complete and expand the new version, please let me know :-)
The background music code looks like a really nice feature.

@sylakone2, are all your issues resolved or do i need to debug something?
SoulMate
great white shark
 
Posts: 79
Joined: Wed, 14Apr23 17:56
sex: Masculine

Re: Web Based Adventure (WBA)

Postby Super » Thu, 15Jun18 21:16

I'll be able to just port Envying Celina to the new one, right?

Also, will I still need to download the .js file and cut and paste it from downloads to the folder, or will that be fixed?

Game flow looks good. Will it factor in the checks? Currently have a huge conversation with six different variables to initiate different parts of conversation that's making my head hurt so I could appreciate anything to help there lol

Thanks
Super
legend of the South Seas
 
Posts: 545
Joined: Wed, 11Aug24 20:59
sex: Masculine

Re: Web Based Adventure (WBA)

Postby SoulMate » Thu, 15Jun18 22:06

Yeah, porting is easy because data.js keeps exactly the same. You wont even notice the changes if i did my work right ;-)

The downloading can't be fixed (at the moment). For security reasons browsers won't let the webpage decide where to put the data.js. So for now thats the only way.
If anyone knows a workaround for this issue, ill be glad to hear.

The overview only shows which pages are linked together, but doesn't account if the checks are satisfied.
This is in the current form not possible because the build engine does not know what variable has which value.
Maybe i can make something where you can put variable/values pairs to start with and then shows with green/red arrows what paths are accessible.
Sounds possible, but don't know the impact on the performance when many pages are involved.
Is the above something you be helped with?
SoulMate
great white shark
 
Posts: 79
Joined: Wed, 14Apr23 17:56
sex: Masculine

Re: Web Based Adventure (WBA)

Postby sylakone2 » Fri, 15Jun19 03:53

SoulMate wrote:Hey Kex,
Thx for the fixes and support to other users. I really appreaciate it.

Currently i'm working on a full rewrite of the build module. It looks exactly the same, but is written in AngularJS. This allow me (and eventually other developers - kex?) to scale and develop quicker in the future. Most of the work is done, but there are still a few missing features that were available in the previous version. When all features are ready i'll release the version.

The debug and play will stay exactly the same.

I Also updated the overview module by using the js vis plugin to visualize the game flow better:
Image

@kex, if your interested to help complete and expand the new version, please let me know :-)
The background music code looks like a really nice feature.

@sylakone2, are all your issues resolved or do i need to debug something?


HI Soul

Good to see you are still around :)

The only problem I am having with it at the moment is with the debug mode for some strange reason one of my pages in debug mode is missing 2 of its imagemaps but if you play it in normal mode it works fine.
KEx was going to have a look at it for me I have not worried too much about it as it is low priority.

I really like the look of your new changes .

Cheers

Sy
Cheers Sy
User avatar
sylakone2
lagoon predator
 
Posts: 224
Joined: Mon, 12Jan09 13:08
Location: Australia, SA
sex: Masculine

Re: Web Based Adventure (WBA)

Postby Super » Fri, 15Jun19 04:00

You don't need to worry about me, I was just checking if that worked, I can figure it out myself
Super
legend of the South Seas
 
Posts: 545
Joined: Wed, 11Aug24 20:59
sex: Masculine

Re: Web Based Adventure (WBA)

Postby Super » Sat, 15Jun27 20:01

So I decided I wanted to try and develop a Fantasy RPG/ dating sim with this while still working on Envying Celina in my spare time. And I decided to continue using this as it isn't as easy to cheat by editing HTML (though that's probably just my inability to not do that)

Anyway, before I get too knee deep into it, I want to know if it's possible to create objects yet. I think I could work up a basic math system for battles and I know that real programming creates objects. So basically, is it possible yet to create an instance of, say, a Goblin, give him 4 or 5 variables, and be able to call him and all his variables over and over from scratch?

If I'm not mistaken, I would go into Game Variables, create variables like EnemyHealth, EnemyAttack and so on, then create an object in custom.js for each enemy where I call all the Enemy variables and assign them a value for that particular enemy, and then call that function in the particular battle? It's been a while since I took programming but I think I have a basic idea of what I'd need to do, I just want to know if there is a better way.

EDIT: I think I managed to work out a way... I'll just try and create a short demo my way before posting it to see if there's a better way. If nothing else, it's a great learning exercise.
Super
legend of the South Seas
 
Posts: 545
Joined: Wed, 11Aug24 20:59
sex: Masculine

Re: Web Based Adventure (WBA)

Postby sylakone2 » Sat, 15Sep12 13:44

Hi Guys

Just a quick one.

I cant seem to find a way to do it after a few hours of searching.
In WBA how can I set a variable to a random number?

Cheers

Sy
Cheers Sy
User avatar
sylakone2
lagoon predator
 
Posts: 224
Joined: Mon, 12Jan09 13:08
Location: Australia, SA
sex: Masculine

Re: Web Based Adventure (WBA)

Postby sylakone2 » Sun, 15Sep13 22:56

I spose a bit more clarity . I'm trying to do a kind of mini game like spin the bottle so I want to say click a button called spin then it randomly sets the spin variable to number between 1 & 6 then with a redirect page I can switch to showing the character the bottle is pointing at.

Cheers

Sy
Cheers Sy
User avatar
sylakone2
lagoon predator
 
Posts: 224
Joined: Mon, 12Jan09 13:08
Location: Australia, SA
sex: Masculine

Re: Web Based Adventure (WBA)

Postby SoulMate » Thu, 15Oct22 00:10

Hi sylakone2,

Sorry for the late answer.
You can make a page with a 'random' block.
In the random block you can add multiple pages.
When a user lands on the random page, he is redirected to one of the random pages.

If you create 6 pages with all the 6 results your good.
SoulMate
great white shark
 
Posts: 79
Joined: Wed, 14Apr23 17:56
sex: Masculine

Re: Web Based Adventure (WBA)

Postby sylakone2 » Thu, 15Oct22 10:47

Thanks Soul

I did not even notice that it was there lol.

Another question how do we do animations with WBA?
Just create an animated Gif and go from there?

Cheers

Sy
Cheers Sy
User avatar
sylakone2
lagoon predator
 
Posts: 224
Joined: Mon, 12Jan09 13:08
Location: Australia, SA
sex: Masculine

PreviousNext

Return to The workshop of creators

Who is online

Users browsing this forum: No registered users and 17 guests

eXTReMe Tracker