-
Notifications
You must be signed in to change notification settings - Fork 17
CSS
CSS, Cascading Style Sheets, is the standard way to add styling to a web page. It is actually a pretty complicated topic, so this is only going to be a fairly superficial overview.
CSS styling can be defined in several places, and the format is slightly different depending on where it is done, but we will start with the CSS file. In Quest 6, this is style.css.
A CSS definition has two parts; a selector and a declaration. The declaration can itself be composed of several properties, where each property consists of a name and a value - just like attributes in Quest in fact, except each line ends with a semi-colon, not a comma. Here is an example:
p {
color: red;
}
Here "p" is the selector. It tells the browser that this styling is to be applied to all elements with the tag name "p" (which is standard paragraph text). The declaration is contained within the curly braces, between {
and }
; in this case just one property. The name is "color", the value is "red". Note that they are separated by a colon, and terminated by a semi-colon.
That example was simple enough, but selectors can be very complex.
To select a specific element, give the element an "id" attribute in the HTML, then use #
before that in the selector.
<div id="red-text">Some text</div>
#red-text {
color: red;
}
To select a set of elements, give the elements a "class" attribute, then use .
before that in the selector.
<div class="red-text">Some text</div>
.red-text {
color: red;
}
You can combine selectors in complex ways, and there are a couple of examples on this page. For more details, I recommend this page.
There is a huge number of properties Some of the more common are:
color
background-color
font-family
font-size
font-weight (for bold)
font-style (for italic)
text-decoration (for underline)
text-align
border
margin
padding
The last three can be set for each side individually, so border-left
, border-top
, etc. More here.
CSS can be applied as an attribute in HTML. This is done with the style attribute, and the value should be the bit from within the curly braces.
<div style="color:red;font-style:italic;">Some text</div>
You can also apply styling using JavaScript...
The general approach is to get the HTML element, using document.querySelector
, together with the selector. Prefix with .
for a class or #
for an ID as normal for CSS. Attributes are accessed via the "style" attribute. For example:
document.querySelector('#text-dialog').style.width = '100px'
document.querySelector('#text-dialog').style.backgroundColor = 'red'
Note:
- when setting a value with units, there must be no space between the value and the units
- CSS attributes that are two words much be converted to camel-case
Tutorial
- First steps
- Rooms and Exits
- Items
- Templates
- Items and rooms again
- More items
- Locks
- Commands
- Complex mechanisms
- Uploading
QuestJS Basics
- General
- Settings
- Attributes for items
- Attributes for rooms
- Attributes for exits
- Naming Items and Rooms
- Restrictions, Messages and Reactions
- Creating objects on the fly
- String Functions
- Random Functions
- Array/List Functions
- The
respond
function - Other Functions
The Text Processor
Commands
- Introduction
- Basic commands (from the tutorial)
- Complex commands
- Example of creating a command (implementing SHOOT GUN AT HENRY)
- More on commands
- Shortcut for commands
- Modifying existing commands
- Custom parser types
- Note on command results
- Meta-Commands
- Neutral language (including alternatives to "you")
- The parser
- Command matching
- Vari-verbs (for verbs that are almost synonyms)
Templates for Items
- Introduction
- Takeable
- Openable
- Container and surface
- Locks and keys
- Wearable
- Furniture
- Button and Switch
- Readable
- Edible
- Vessel (handling liquids)
- Components
- Countable
- Consultable
- Rope
- Construction
- Backscene (walls, etc.)
- Merchandise (including how to create a shop)
- Shiftable (can be pushed from one room to another)
See also:
- Custom templates (and alternatives)
Handing NPCs
- Introduction
- Attributes
- Allowing the player to give commands
- Conversations
- Simple TALK TO
- SAY
- ASK and TELL
- Dynamic conversations with TALK TO
- TALK and DISCUSS
- Following an agenda
- Reactions
- Giving
- Followers
- Visibility
- Changing the player point-of-view
The User Experience (UI)
The main screen
- Basics
- Printing Text Functions
- Special Text Effects
- Output effects (including pausing)
- Hyperlinks
- User Input
The Side Panes
Multi-media (sounds, images, maps, etc.)
- Images
- Sounds
- Youtube Video (Contribution by KV)
- Adding a map
- Node-based maps
- Image-based maps
- Hex maps
- Adding a playing board
- Roulette!... in a grid
Dialogue boxes
- Character Creation
- Other example dialogs [See also "User Input"]
Other Elements
- Toolbar (status bar across the top)
- Custom UI Elements
Role-playing Games
- Introduction
- Getting started
- Items
- Characters (and Monsters!)
- Spawning Monsters and Items)
- Systema Naturae
- Who, When and How NPCs Attack
- Attributes for characters
- Attacking and guarding
- Communicating monsters
- Skills and Spells
- Limiting Magic
- Effects
- The Attack Object
- [Extra utility functions](https://github.com/ThePix/QuestJS/wiki/RPG-Library-%E2%80%90-Extra Functions)
- Randomly Generated Dungeon
- Quests for Quest
- User Interface
Web Basics
- HTML (the basic elements of a web page)
- CSS (how to style web pages)
- SVG (scalable vector graphics)
- Colours
- JavaScript
- Regular Expressions
How-to
Time
- Events (and Turnscripts)
- Date and Time (including custom calendars)
- Timed Events (i.e., real time, not game time)
Items
- Phone a Friend
- Using the USE verb
- Display Verbs
- Change Listeners
- Ensembles (grouping items)
- How to spit
Locations
- Large, open areas
- Region,s with sky, walls, etc.
- Dynamic Room Descriptions
- Transit system (lifts/elevators, buses, trains, simple vehicles)
- Rooms split into multiple locations
- Create rooms on the fly
- Handling weather
Exits
- Alternative Directions (eg, port and starboard)
- Destinations, Not Directions
Meta
- Customise Help
- Provide hints
- Include Achievements
- Add comments to your code
-
End The Game (
io.finish
)
Meta: About The Whole Game
- Translate from Quest 5
- Authoring Several Games at Once
- Chaining Several Games Together
- Competition Entry
- Walk-throughs
- Unit testing
- Debugging (trouble-shooting)
Releasing Your Game
Reference
- The Language File
- List of settings
- Scope
- The Output Queue
- Security
- Implementation notes (initialisation order, data structures)
- Files
- Code guidelines
- Save/load
- UNDO
- The editor
- The Cloak of Darkness
- Versions
- Quest 6 or QuestJS
- The other Folders
- Choose your own adventure