Front | Side | Back |
---|---|---|
Death |
---|
- Run
mix deps.get
in the main dir - Run
mix ecto.create
in the main dir - Run
yarn
inapps/bear_necessities_web/assets
Start with mix phx.server, go to https://localhost:4000/ and wait for the assets to compile
Multiplayer bear game with Phoenix Live View
Home Page: https://unbearable.nl/
Front | Side | Back |
---|---|---|
Death |
---|
mix deps.get
in the main dirmix ecto.create
in the main diryarn
in apps/bear_necessities_web/assets
Start with mix phx.server, go to https://localhost:4000/ and wait for the assets to compile
At the moment the grass texture variant is based on a random number. The problem with this approach is that the texture changes while walking.
So we somehow want to determine and store the texture state on the server, for example as %Grass{texture: 2}
and %Tree{texture: 4}
.
This also means that tiles can have multiple layers, for example:
[
%Grass{texture: 2},
%Tree{texture: 4}
]
Thoughts on this?
Would something like this make sense?
%Game{
field: [
# row 1 (11 tiles)
[
%Tile{layers: [%Grass{texture: 2}]},
%Tile{layers: [
%Grass{texture: 2},
%Bear{}
]},
%Tile{id: 3, layers: [%Grass{texture: 4}]},
# ...
],
# row 2 (11 tiles)
[
%Tile{layers: [%Grass{texture: 3}]},
%Tile{layers: [%Grass{texture: 2}]},
%Tile{layers: [
%Grass{texture: 1}
%Tree{texture: 3}
]},
# ...
]
# 9 more rows ...
]
}
related #28
Matrices are used in most tile-based games afaik. For Elixir there is the Matrix modules which might be helpful. Not sure if this is something for us.
const map = {
cols: 8,
rows: 8,
tsize: 64,
tiles: [
1, 3, 3, 3, 1, 1, 3, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 2, 1, 1, 1, 1,
1, 1, 1, 1, 2, 1, 1, 1,
1, 1, 1, 1, 2, 1, 1, 1,
1, 1, 1, 0, 0, 1, 1, 1
],
getTile: (col, row) => {
return this.tiles[row * map.cols + col]
}
};
translated to:
Possibility to monitor the bears and let the monitor send a message to clear the bear from state if the bear process is killed.
Scrollbars interfere with game controls
When clawing multiple times in under 1000ms, the animation will not finish anymore. Something with the decreasing timer in Player.handle_info/2
for :update_claw
Hide them in trees, or let them follow bears that are closest maybe?
This should slow the movement of the bear and remove some honey?
Need one
use arrow keys to move
use space bar to get honey from trees and other bears
So you can see all the connected players
Seems like I don't hear sound on safari.
Version 12.0.3 (14606.4.5)
After the client connects,
mount/2
will be invoked inside a spawned
LiveView process. At this point, you can useconnected?/1
to
conditionally perform stateful work, such as subscribing to pubsub topics,
sending messages, etc. For example, you can periodically update a LiveView
with a timer:
defmodule DemoWeb.ThermostatLive do
use Phoenix.LiveView
...
def mount(%{id: id, current_user_id: user_id}, socket) do
if connected?(socket), do: :timer.send_interval(30000, self(), :update)
case Thermostat.get_user_reading(user_id, id) do
{:ok, temperature} ->
{:ok, assign(socket, temperature: temperature, id: id)}
{:error, reason} ->
{:error, reason}
end
end
def handle_info(:update, socket) do
{:ok, temperature} = Thermostat.get_reading(socket.assigns.id)
{:noreply, assign(socket, :temperature, temperature)}
end
end
We usedconnected?(socket)
on mount to send our view a message every 30s if
the socket is in a connected state. We receive:update
in a
handle_info
just like a GenServer, and update our socket assigns. Whenever
a socket's assigns change,render/1
is automatically invoked, and the
updates are sent to the client.
I think we could use this to update the view every few milliseconds/seconds(?) to return the state of where other bees/bears are
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.