Giter Site home page Giter Site logo

bearnecessities's Introduction

BearNecessities.Umbrella

Front Side Back
front left back
front-attack left-attack back-attack
Death
ded

Install

  • Run mix deps.get in the main dir
  • Run mix ecto.create in the main dir
  • Run yarn in apps/bear_necessities_web/assets

Running

Start with mix phx.server, go to https://localhost:4000/ and wait for the assets to compile

bearnecessities's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar easterpeanut avatar fatboypunk avatar fritsypeij avatar richardvdveen avatar sn3p avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

laymer

bearnecessities's Issues

Determine texture variants on the server

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.

https://github.com/fatboypunk/BearNecessities/blob/6eef3deb0b4549098ce88ea7b414385602946e13/apps/bear_necessities_web/lib/bear_necessities_web/views/playfield.ex#L7

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 ...
  ]
}

Use Matrix for Tile Map?

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.

Some resources on this

Basic example from the demo above

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:

no-scroll

Add bees

Hide them in trees, or let them follow bears that are closest maybe?

Add a bear trap

This should slow the movement of the bear and remove some honey?

Upate the view to show where other bears are

After the client connects, mount/2 will be invoked inside a spawned
LiveView process. At this point, you can use connected?/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 used connected?(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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.